Submission #6015649
Source Code Expand
#include <iostream> #include <vector> #include <map> using namespace std; vector<pair<int,int>> d(4); d[0] = make_pair(1,0); d[1] = make_pair(0,1); d[2] = make_pair(-1,0); d[3] = make_pair(0,-1); int check(int w, int h, vector<vector<char>> &V, vector<vector<bool>> &C){ int tmp = 1; //黒の連結成分に含まれる黒の数をadjにpush_back for(int i = 0; i < 4; i++){ int wp = w + d[i].first; int hp = h + d[i].second; if(wp < 0 || wp > W - 1 || hp < 0 || hp > H - 1)continue; if(V[wp][hp] == '#'){ tmp += check(wp, hp); C[wp,hp] = true; } } return tmp; } int main(){ int H, W; cin >> H >> W; vector<vector<char>> V(H,vector<char> (W,'x')); for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ cin >> V[i][j]; } } vector<int> adj; vector<vector<bool>> C(H,vector<bool> (W,false)); for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(C[i][j])continue; if(C[i][j] == '#'){ adj.push_back(check(i ,j ,V, C)); } C[i][j] = true; } } sort(adj.begin(), adj.end()); if(adj[0] <= 1) cout << "Yes"; else cout << "No"; }
Submission Info
Submission Time | |
---|---|
Task | C - Grid Repainting 2 |
User | otsuyutori |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1215 Byte |
Status | CE |
Compile Error
./Main.cpp:8:1: error: ‘d’ does not name a type d[0] = make_pair(1,0); ^ ./Main.cpp:9:1: error: ‘d’ does not name a type d[1] = make_pair(0,1); ^ ./Main.cpp:10:1: error: ‘d’ does not name a type d[2] = make_pair(-1,0); ^ ./Main.cpp:11:1: error: ‘d’ does not name a type d[3] = make_pair(0,-1); ^ ./Main.cpp: In function ‘int check(int, int, std::vector<std::vector<char> >&, std::vector<std::vector<bool> >&)’: ./Main.cpp:19:25: error: ‘W’ was not declared in this scope if(wp < 0 || wp > W - 1 || hp < 0 || hp > H - 1)continue; ^ ./Main.cpp:19:49: error: ‘H’ was not declared in this scope if(wp < 0 || wp > W - 1 || hp < 0 || hp > H - 1)continue; ^ ./Main.cpp:21:28: error: too few arguments to function ‘int check(int, int, std::vector<std::vector<char> >&, std::vector<std::vector<bool> >&)’ tmp += check(wp, hp); ^ ./Main.cpp:13:5: note: declared here int check(int w, int h, ve...