Submission #1066176

#TimeUsernameProblemLanguageResultExecution timeMemory
1066176deeraSoccer Stadium (IOI23_soccer)C++17
18 / 100
4512 ms45720 KiB
#include <bits/stdc++.h> using namespace std; struct Pos { int x, y; Pos(int x, int y) : x(x), y(y) {} }; bool FIELD[2001][2001] = {0}; // bool empty(int a, int b, int x, int y) { // assert(a == x || b == y); // only 1d queries // if (a == x) // for (int i = min(b, y); i <= max(b, y); i++) // if (FIELD[a][i]) return false; // if (b == y) // for (int i = min(a, x); i <= max(a, x); i++) // if (FIELD[i][b]) return false; // return true; // } int biggest_stadium(int N, vector<vector<int>> F) { vector<Pos> trees; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { if (F[i][j] == 1) trees.push_back({i, j}); FIELD[i][j] = F[i][j]; } for (auto tree : trees) { cerr << tree.x << " " << tree.y << endl; } if (trees.size() == 0) return N * N; if (trees.size() == 1) { int x = trees[0].x, y = trees[0].y; int n = N - 1; int a = (abs(x - 0) + 1) * (abs(y - 0) + 1); int b = (abs(x - 0) + 1) * (abs(y - n) + 1); int c = (abs(x - n) + 1) * (abs(y - 0) + 1); int d = (abs(x - n) + 1) * (abs(y - n) + 1); return N * N - min({a, b, c, d}); } const int MAXN = 500; set<set<pair<int, int>>> cover; set<pair<int, int>> last; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { if (FIELD[i][j] == 1) continue; const int DIRS[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; // x, y and direction and the kick // 0 = first kick, 1 = second kick queue<tuple<int, int, int, bool>> q; bool used[MAXN][MAXN][4][2] = {0}; bool visited[MAXN][MAXN] = {0}; set<pair<int, int>> vis; visited[i][j] = true; vis.insert({i, j}); for (int d = 0; d < 4; d++) { used[i][j][d][0] = true; q.push({i, j, d, 0}); } while (!q.empty()) { auto [x, y, d, k] = q.front(); q.pop(); x += DIRS[d][0]; y += DIRS[d][1]; if (x < 0 || x >= N || y < 0 || y >= N) continue; if (FIELD[x][y]) continue; if (used[x][y][d][k]) continue; visited[x][y] = true; vis.insert({x, y}); used[x][y][d][k] = true; q.push({x, y, d, k}); if (k == true) continue; for (int d = 0; d < 4; d++) { used[x][y][d][1] = true; q.push({x, y, d, 1}); } } cover.insert(vis); last = vis; cerr << "ceverage from " << i << " " << j << endl; for (int a = 0; a < N; a++) { for (int b = 0; b < N; b++) { if (a == i && b == j) cerr << "@"; else if (FIELD[a][b]) cerr << "#"; else if (visited[a][b]) cerr << "+"; else cerr << " "; cerr << " "; } cerr << '\n'; } } if (cover.size() == 1 && last.size() == N * N - trees.size()) return N * N - trees.size(); return 0; // for (int a = 0; a < N; a++) for (int b = 0; b < N; b++) { // for (int x = 0; x < N; x++) for (int y = 0; y < N; y++) { // // going throgh (a, y) // if (a == x && b == y) continue; // if (FIELD[a][b] || FIELD[x][y]) continue; // if ((empty(a, b, a, y) && empty(x, y, a, y)) // || empty(a, b, x, b) && empty(x, y, x, b)) { // continue; // } else {return 0;} // } // } // return N * N - trees.size(); }
#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...