Submission #1238157

#TimeUsernameProblemLanguageResultExecution timeMemory
1238157matsakyannnSoccer Stadium (IOI23_soccer)C++20
1.50 / 100
205 ms35808 KiB
#include <bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define dbg(x) cerr << #x << ' '; print(x); cerr << endl; #else #define dbg(x) #endif void print(int x) {cerr << x;} void print(long long x) {cerr << x;} void print(char x) {cerr << x;} void print(string x) {cerr << x;} void print(double x) {cerr << x;} template <class T> void print(vector <T> x); template <class T> void print(set <T> x); template <class T> void print(multiset <T> x); template <class T, class V> void print(pair <T, V> x); template <class T, class V> void print(map <T, V> x); template <class T> void print(vector <T> x) {cerr << "[ "; for(auto i : x) {print(i); cerr << ' ';} cerr << "]";} template <class T> void print(set <T> x) {cerr << "[ "; for(auto i : x) {print(i); cerr << ' ';} cerr << "]";} template <class T> void print(multiset <T> x) {cerr << "[ "; for(auto i : x) {print(i); cerr << ' ';} cerr << "]";} template <class T, class V> void print(pair <T, V> x) {cerr << "{"; print(x.first); cerr << ' '; print(x.second); cerr << "}";} template <class T, class V> void print(map <T, V> x) {cerr << "[ "; for(auto i : x) {print(i); cerr << ' ';} cerr << "]";} #define ll long long #define pb push_back #define ppb pop_back #define PII pair <int, int> #define PLL pair <ll, ll> #define all(v) (v).begin(), (v).end() #define OK cerr << "OK\n"; #define MP make_pair int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; const int inf = 1e9; int biggest_stadium(int N, vector <vector <int>> F){ bool okay = 1; for(int i = 0; i < N; i++){ int st = -1; for(int j = 0; j < N; j++){ if(!F[i][j]){ st = j; break; } } if(st == -1) continue; bool tree_on_road = 0; for(int j = st; j < N; j++){ if(F[i][j]){ tree_on_road = 1; continue; } if(tree_on_road) okay = 0; } } for(int j = 0; j < N; j++){ int st = -1; for(int i = 0; i < N; i++){ if(!F[i][j]){ st = i; break; } } if(st == -1) continue; bool tree_on_road = 0; for(int i = st; i < N; i++){ if(F[i][j]){ tree_on_road = 1; continue; } if(tree_on_road) okay = 0; } } if(okay){ int count = 0; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ count += F[i][j]; } } int vis_count = 0; for(int i = 0; i < N; i++){ bool flag = 0; for(int j = 0; j < N; j++){ if(!F[i][j]){ flag = 1; bool visited[2005][2005] = {0}; queue <PII> q; q.push({i, j}); while(!q.empty()){ int x = q.front().first, y = q.front().second; //dbg(MP(x, y)); q.pop(); if(visited[x][y]) continue; vis_count++; visited[x][y] = 1; for(int t = 0; t < 4; t++){ int nx = x + dx[t], ny = y + dy[t]; if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue; if(F[nx][ny]) continue; q.push({nx, ny}); } } break; } } if(flag) break; } if(vis_count == N * N - count) return N * N - count; } return inf; }
#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...