2020-01-01から1年間の記事一覧
作り方は公式のサイトを参考にしました。 https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScriptわからなかった所を書いていきます。 まず、パドルの操作で一つ分からなかった所がるんですが、まずは以下のコードを見…
URL https://matsudasan.github.io/Noughts-and-Crosses/reactのチュートリアルをjsで書き直した程度ですが。
今回はjsのみでランキング作成サイトを作ってみました https://matsudasan.github.io/Creat-Ranking/画像をドラッグ&ドロップすることで画面に反映されます。
しゃくとり法に関しては下記URLのスライド55ページ~を参考にどうぞ https://www.slideshare.net/yuki2006_debel/21-35882983ポイントとしては条件に一致するまでrightを動かしていき、処理が終わったらleftを動かす。この時rightの値はそのままにする。問題…
A - Rounding かかった時間 2分 実行時間 29ms X,A=map(int,input().split()) if A>X: print(0) else: print(10) B - Bounding かかった時間 3分 実行時間 22ms N,X=map(int,input().split()) L=list(map(int,input().split())) ans=1 num=0 for i in L: num…
A - Security https://atcoder.jp/contests/abc131/tasks/abc131_a かかった時間 2分 実行時間 26ms S=str(input()) for i in range(len(S)-1): if S[i]==S[i+1]: print("Bad") exit() print("Good") B - Bite Eating https://atcoder.jp/contests/abc131/ta…
フレームワークをつかわずにhtml,css,javascriptのみでアプリを作ってみました。一つ目のアプリ:Todoアプリ https://matsudasan.github.io/Todo-js-/ リポジトリ:https://github.com/matsudasan/Todo-js- とりあえず、基本となるTodoアプリを作りました。 R…
今回はクラスカル法をやっていきます。使用する問題は以下になります。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jaまず、入力から from heapq import heappush,heappop,heapify V,E=map(int,input().split()) Graph=[[] for…
今回はワーシャルフロイド法をやっていきます。 使用する問題は以下になります。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jaまず、入力から V,E=map(int,input().split()) INF=10**10 dp=[[INF]*V for _ in range(V)]#隣接…
今回はベルマン・フォード法をやっていきます。使用する問題は下記URLのものを使います。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B&lang=jaまず、入力から INF=10**9 V,E,r=map(int,input().split()) Graph=[list(map(int,input()…
今回はダイクストラ法をやっていきます。 まず、ダイクストラ法の説明については下記動画がとてもわかりやすいです。 https://youtu.be/X1AsMlJdiokちなみにダイクストラ法では負の辺があるとき使えません。 負の辺があるときはベルマン・フォード法を使いま…
今回は幅優先探索(BFS)をやっていきます。 幅優先探索は各頂点への最短経路を求めることのできるアルゴリズムですが、辺に移動距離や時間などを考慮しないため、使う際は注意が必要。 今回は以下のグラフを使います。 頂点が8個、辺が8個のグラフです。 なの…
今回は深さ優先探索(DFS)をやっていきます。 問題は下記URLのを使います http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B&lang=ja n=int(input()) Graph=[list(map(int, input().split())) for _ in range(n)] start=[0]*(n)#頂点の発…
今回は二分木探索をやっていきます。 以下の記事で使ったことがあるので、その問題で今回はやっていきます。 コードもそこから流用します。 nasubifx.hatenablog.com問題URL https://atcoder.jp/contests/abc146/tasks/abc146_c二分木探索を使う場合は全探索…
今回で動的計画法(DP)の最後です bitdpを使うと全探索がn 今回は以下の問題を使用します。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_A&lang=ja 有名な巡回セールスマン問題(TSP)ですね。 V,E=map(int, input().split()) #でかい値な…
今回は区間DPをやっていきます。 理解するまでに時間がかかりましたが、理解できればなるほどと思いました。 例題は以下の問題でやっていきます。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1611&lang=jp とりあえず、 4 1 2 3 4与えられる…
今回からAtCoderのD問題を解くためにアルゴリズムの勉強を始めます。https://atcoder.jp/contests/abc032/tasks/abc032_d 上記の例でナップサックDPを使っていきます。 以下は上記の例の入力例1の場合で書いていきます。 N,W=map(int,input().split()) value…
まず、以下が完成品です https://matsudasan.github.io/Trello/使ったライブラリはreact-beautiful-dndです。 https://github.com/atlassian/react-beautiful-dnd最初はreact-dndを使っていたんですが、react-beautiful-dndのサンプルにTrelloに似ているもの…
A - Fifty-Fifty https://atcoder.jp/contests/abc132/tasks/abc132_a かかった時間 8分 実行時間 30ms import collections S=list(str(input())) num=collections.Counter(S) for i,j in num.items(): if j!=2: print("No") exit() print("Yes") B - Ordina…
A - T or T https://atcoder.jp/contests/abc133/tasks/abc133_a かかった時間 1分 実行時間 24ms N,A,B=map(int,input().split()) print(min(N*A,B)) B - Good Distance https://atcoder.jp/contests/abc133/tasks/abc133_b かかった時間 30分 実行時間 185…
エディタを作るにあたりreact-aceを使いました。 https://github.com/securingsincity/react-ace完成品 https://matsudasan.github.io/HTMLEditor/本当はリサイズ可能にしたかったんですが、やり方がわかりませんでした。 次は、paiza.ioのようなオンライン…
A - Dodecagon https://atcoder.jp/contests/abc134/tasks/abc134_a かかった時間 1分 実行時間 25ms r=int(input()) print(3*r**2) B - Golden Apple https://atcoder.jp/contests/abc134/tasks/abc134_b かかった時間 15分 実行時間 27ms N,D=map(int,inpu…
A - Harmony https://atcoder.jp/contests/abc135/tasks/abc135_a かかった時間 12分 実行時間 24ms A,B=map(int,input().split()) if (A+B)%2==0: print(int((A+B)/2)) else: print("IMPOSSIBLE") 入力例を見た感じAとBを足して2で割ったら答えになり、それ…
今回からAtCoderに登録したのでコードは全部通ります A - Transfer https://atcoder.jp/contests/abc136/tasks/abc136_a かかった時間 4分 実行時間 30ms A,B,C=map(int,input().split()) print(max(C-(A-B),0)) なんか、WAになるなと思っていたら、print(C-…
A - +-x https://atcoder.jp/contests/abc137/tasks/abc137_a かかった時間 1分30秒 A,B=map(int,input().split()) p=A+B h=A-B k=A*B print(max(p,h,k)) B - One Clue https://atcoder.jp/contests/abc137/tasks/abc137_b かかった時間 4分 K,X=map(int,inp…
最近はAtCoderの問題ばかり解いていたので、わすれないように今回はReactでアプリを作ってみました 以下のURLがそのアプリです https://matsudasan.github.io/Folder-Tree/ ただ、バグが1個あって、ツリーの最後がフォルダだと中途半端に縦線が伸びちょうん…
A - Red or Not https://atcoder.jp/contests/abc138/tasks/abc138_a かかった時間 2分 a=int(input()) s=str(input()) if a>=3200: print(s) else: print("red") B - Resistors in Parallel https://atcoder.jp/contests/abc138/tasks/abc138_b かかった時…
A - Tenki https://atcoder.jp/contests/abc139/tasks/abc139_a かかった時間 1分30秒 S=str(input()) T=str(input()) ans=0 for i in range(3): if S[i]==T[i]: ans+=1 print(ans) B - Power Socket https://atcoder.jp/contests/abc139/tasks/abc139_b か…
A - Password https://atcoder.jp/contests/abc140/tasks/abc140_a かかった時間 5分30秒 N=int(input()) print(N**3) B - Buffet https://atcoder.jp/contests/abc140/tasks/abc140_b かかった時間 15分 N=int(input()) A=list(map(int,input().split())) B…
A - Weather Prediction https://atcoder.jp/contests/abc141/tasks/abc141_a かかった時間 1分30秒 S=str(input()) if S=="Sunny": print("Cloudy") elif S=="Cloudy": print("Rainy") else: print("Sunny") B - Tap Dance https://atcoder.jp/contests/abc…