Particle

競技プログラミングについての雑記

2012-04-07から1日間の記事一覧

AOJ 0535: Crossing Black Ice

AOJ

DFS(深さ優先探索)の典型問題。m+2 × n+2のマップを使うとマップ外に出なくなるのでオススメです。 #include<cstdio> #include<algorithm> using namespace std; int m,n,unused[90][90],dx[] = {1,0,-1,0},dy[] = {0,1,0,-1}; int dfs(int y, int x, int d){//座標と、今までに</algorithm></cstdio>…

AOJ 0534: Chain

AOJ

実装。色の変え方が最大で2パターンあるので、両方とも試す。 #include<cstdio> #include<algorithm> using namespace std; int n,chain[10000]; int fig(int b){ int a = b-1,c = b+1,color,res = 0; if(a>=0){//b == 0のバターンを弾く int s = 1; color = chain[a]; while(a></algorithm></cstdio>…