제출 #451168

#제출 시각아이디문제언어결과실행 시간메모리
451168fuad27Tracks in the Snow (BOI13_tracks)C++14
컴파일 에러
0 ms0 KiB
    	v[i][j] = '#';
    	visited[i][j] = true;
    	dfs(v, i+1, j, k);
    	dfs(v, i-1, j, k);
    	dfs(v, i, j+1, k);
    	dfs(v, i, j-1, k);	
    }
    }
    int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    v.resize(h, vector<char> (w));
    for(int i = 0;i<h;i++) {
    	for(int j = 0;j<w;j++) {
    		cin >> v[i][j];
    	}
    }
    queue<pair<int, int>> q;
    q.push({0, 0});
    vector<vector<int>> visi(h, vector<int>(w, 0));
    while(!q.empty()) {
    	int x = q.front().first;
    	int y = q.front().second;
    	q.pop();
    	if(v[x][y]!='.' and !visi[x][y]) {
    		visited.assign(h, vector<bool> (w, 0));
    		if(x < h-1 and !visi[x+1][y]) {
    			q.push({x+1, y});
    		}
    		if(y < w -1 and !visi[x][y+1]) {
    			q.push({x, y+1});
    		}
    		if(v[x][y] != '#') {
    		dfs(v, x, y, v[x][y]);
    		ans++;
    	}
    	visi[x][y] = 1;
    }
    }
    cout<<ans<<endl;
     
    }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp:1:6: error: 'v' does not name a type
    1 |      v[i][j] = '#';
      |      ^
tracks.cpp:2:6: error: 'visited' does not name a type
    2 |      visited[i][j] = true;
      |      ^~~~~~~
tracks.cpp:3:9: error: expected constructor, destructor, or type conversion before '(' token
    3 |      dfs(v, i+1, j, k);
      |         ^
tracks.cpp:4:9: error: expected constructor, destructor, or type conversion before '(' token
    4 |      dfs(v, i-1, j, k);
      |         ^
tracks.cpp:5:9: error: expected constructor, destructor, or type conversion before '(' token
    5 |      dfs(v, i, j+1, k);
      |         ^
tracks.cpp:6:9: error: expected constructor, destructor, or type conversion before '(' token
    6 |      dfs(v, i, j-1, k);
      |         ^
tracks.cpp:7:5: error: expected declaration before '}' token
    7 |     }
      |     ^
tracks.cpp:8:5: error: expected declaration before '}' token
    8 |     }
      |     ^
tracks.cpp: In function 'int main()':
tracks.cpp:10:5: error: 'ios_base' has not been declared
   10 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
tracks.cpp:11:5: error: 'cin' was not declared in this scope
   11 |     cin.tie(0);
      |     ^~~
tracks.cpp:12:5: error: 'cout' was not declared in this scope
   12 |     cout.tie(0);
      |     ^~~~
tracks.cpp:13:12: error: 'h' was not declared in this scope
   13 |     cin >> h >> w;
      |            ^
tracks.cpp:13:17: error: 'w' was not declared in this scope
   13 |     cin >> h >> w;
      |                 ^
tracks.cpp:14:5: error: 'v' was not declared in this scope
   14 |     v.resize(h, vector<char> (w));
      |     ^
tracks.cpp:14:17: error: 'vector' was not declared in this scope
   14 |     v.resize(h, vector<char> (w));
      |                 ^~~~~~
tracks.cpp:14:24: error: expected primary-expression before 'char'
   14 |     v.resize(h, vector<char> (w));
      |                        ^~~~
tracks.cpp:20:5: error: 'queue' was not declared in this scope
   20 |     queue<pair<int, int>> q;
      |     ^~~~~
tracks.cpp:20:11: error: 'pair' was not declared in this scope
   20 |     queue<pair<int, int>> q;
      |           ^~~~
tracks.cpp:20:16: error: expected primary-expression before 'int'
   20 |     queue<pair<int, int>> q;
      |                ^~~
tracks.cpp:21:5: error: 'q' was not declared in this scope
   21 |     q.push({0, 0});
      |     ^
tracks.cpp:22:19: error: expected primary-expression before 'int'
   22 |     vector<vector<int>> visi(h, vector<int>(w, 0));
      |                   ^~~
tracks.cpp:27:27: error: 'visi' was not declared in this scope
   27 |      if(v[x][y]!='.' and !visi[x][y]) {
      |                           ^~~~
tracks.cpp:28:7: error: 'visited' was not declared in this scope
   28 |       visited.assign(h, vector<bool> (w, 0));
      |       ^~~~~~~
tracks.cpp:28:32: error: expected primary-expression before 'bool'
   28 |       visited.assign(h, vector<bool> (w, 0));
      |                                ^~~~
tracks.cpp:36:7: error: 'dfs' was not declared in this scope
   36 |       dfs(v, x, y, v[x][y]);
      |       ^~~
tracks.cpp:37:7: error: 'ans' was not declared in this scope
   37 |       ans++;
      |       ^~~
tracks.cpp:42:11: error: 'ans' was not declared in this scope
   42 |     cout<<ans<<endl;
      |           ^~~
tracks.cpp:42:16: error: 'endl' was not declared in this scope
   42 |     cout<<ans<<endl;
      |                ^~~~