제출 #1238133

#제출 시각아이디문제언어결과실행 시간메모리
1238133matsakyannnSoccer Stadium (IOI23_soccer)C++20
1.50 / 100
189 ms35612 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 flag = 1; int count_trees = 0; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(!F[i][j]) continue; count_trees++; int cnt = 0; for(int t = 0; t < 4; t++){ int nx = i + dx[t], ny = j + dy[t]; if(nx < 0 || ny < 0 || nx >= N || ny >= N){ //dbg(MP(i, j)); cnt++; continue; } cnt += F[nx][ny]; } if(cnt <= 1){ //dbg(MP(i, j)); flag = 0; } } } if(flag){ 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_trees) return N * N - count_trees; } 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...