2011-10-10から1日間の記事一覧
深さ優先探索を初めて解いた。 #include <iostream> std::string map[12]; void dfs(int x,int y){ if(x-1>=0&&map[y][x-1]=='1')map[y][x-1]='0',dfs(x-1,y); if(x+1<=11&&map[y][x+1]=='1')map[y][x+1]='0',dfs(x+1,y); if(y-1>=0&&map[y-1][x]=='1')map[y-1][x]='0'</iostream>…