Submission #831210

#TimeUsernameProblemLanguageResultExecution timeMemory
831210GordonRemzi007Game (eJOI20_game)C++17
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, cnt; pair<int,int> temp; queue<pair<int,int>> q; cin >> n >> m; vector<int> c; vector<string> h(n+1), v(n); vector<vector<bool>> visited(n, vector<bool>(m, false)); for(int i = 0; i <= n; i++) cin >> h[i]; for(int i = 0; i < n; i++) cin >> v[i]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(!visited[i][j] && (h[i][j] == '0' || h[i+1][j] == '0' || v[i][j] == '0' || v[i][j-1] == '0')) { cnt = 0; q.push({i, j}); visited[i][j] = true; while(q.size()) { cnt++; temp = q.front(); q.pop(); if(temp.first != 0 && h[temp.first][temp.second] == '0' && !visited[temp.first-1][temp.second]) { visited[temp.first-1][temp.second] = true; q.push({temp.first-1, temp.second}); } if(temp.first != n-1 && h[temp.first+1][temp.second] == '0' && !visited[temp.first+1][temp.second]) { visited[temp.first+1][temp.second] = true; q.push({temp.first+1, temp.second}); } if(temp.second != 0 && v[temp.first][temp.second] == '0' && !visited[temp.first][temp.second-1]) { visited[temp.first][temp.second-1] = true; q.push({temp.first, temp.second-1}); } if(temp.second != m-1 && v[temp.first][temp.second+1] == '0' && !visited[temp.first][temp.second+1]) { visited[temp.first][temp.second+1] = true; q.push({temp.first, temp.second+1}); } } c.push_back(cnt); } } } sort(c.begin(), c.end()); for(auto i : c) cout << i << "\n"; cout << -c[0] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...