Submission #1076759

#TimeUsernameProblemLanguageResultExecution timeMemory
1076759mickey080929Soccer Stadium (IOI23_soccer)C++17
1.50 / 100
328 ms55432 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int biggest_stadium(int N, vector<vector<int>> F) { vector<vector<int>> vis(N, vector<int>(N, 0)); queue<pair<int,int>> q; for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { if (F[i][j] == 0) { vis[i][j] = 1; q.push({i, j}); break; } } if (!q.empty()) break; } while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); for (int k=0; k<4; k++) { int nx = x + dx[k]; int ny = y + dy[k]; if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue; if (vis[nx][ny]) continue; vis[nx][ny] = 1; q.push({nx, ny}); } } for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { if (F[i][j] == 0 && vis[i][j] == 0) { return 0; } } } int tot = 0; for (int i=0; i<N; i++) { int l = -1, r = -1, cnt = 0; for (int j=0; j<N; j++) { if (F[i][j] == 0) { if (l == -1) l = j; r = j; cnt ++; } } if (cnt != 0 && r - l + 1 != cnt) { return 0; } tot += cnt; } return tot; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...