Submission #1078331

#TimeUsernameProblemLanguageResultExecution timeMemory
1078331PanosPaskSoccer Stadium (IOI23_soccer)C++17
25 / 100
274 ms71408 KiB
#include "soccer.h" using namespace std; typedef pair<int, int> pi; vector<vector<int>> grid; vector<pi> row_range; vector<vector<int>> rotated; vector<pi> column_range; bool check_row(vector<int>& r, vector<pi>& range, int pos) { range[pos] = {-1, -1}; for (int i = 0; i < r.size(); i++) { if (r[i] == 0) { if (range[pos].second != -1) { return false; } if (range[pos].first == -1) { range[pos].first = i; } } else { if (range[pos].first != -1 && range[pos].second == -1) { range[pos].second = i; } } } if (range[pos].second == -1) { range[pos].second = r.size(); } return true; } bool includes(pi a, pi b) { if (b.first == -1) { return true; } return a.first <= b.first && a.second >= b.second; } int biggest_stadium(int N, std::vector<std::vector<int>> F) { grid.resize(N, vector<int>(N)); rotated.resize(N, vector<int>(N)); column_range.resize(N); row_range.resize(N); int tot = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { grid[i][j] = F[i][j]; rotated[j][i] = F[i][j]; tot += !F[i][j]; } } bool good = true; for (int i = 0; i < N; i++) { good = good && check_row(grid[i], row_range, i) && check_row(rotated[i], column_range, i); } if (!good) { return 0; } for (int j = 0; j < N; j++) { if (column_range[j].first == -1) { continue; } pi propagate_range = {-1, -1}; for (int i = 0; i < column_range[j].second; i++) { if (!includes(row_range[i], propagate_range)) { return 0; } if (row_range[i].first != -1) { if (F[i][j]) { propagate_range = row_range[i]; } } } propagate_range = {-1, -1}; for (int i = N - 1; i >= column_range[j].first; i--) { if (!includes(row_range[i], propagate_range)) { return 0; } if (row_range[i].first != -1) { if (F[i][j]) { propagate_range = row_range[i]; } } } } // pi cur = {-1, -1}; // for (int r = 0; r < N; r++) { // if (row_range[r].first != -1) { // if (includes(row_range[r], cur)) { // cur = row_range[r]; // } // else if (!includes(cur, row_range[r])) { // return 0; // } // } // } return tot; }

Compilation message (stderr)

soccer.cpp: In function 'bool check_row(std::vector<int>&, std::vector<std::pair<int, int> >&, int)':
soccer.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...