제출 #841579

#제출 시각아이디문제언어결과실행 시간메모리
841579I_love_Hoang_Yen축구 경기장 (IOI23_soccer)C++17
25 / 100
284 ms31828 KiB
#include <bits/stdc++.h> #include "soccer.h" using namespace std; struct Row { int first, last; int cnt() const { return last - first + 1; } bool contains(const Row& b) const { return first <= b.first && b.last <= last; } bool operator < (const Row& b) const { return cnt() > b.cnt(); } }; pair<bool, int> subtask_25p(int n, const vector<vector<int>>& forest) { int cnt_row = 0; // number of non-empty rows int first_row = n, last_row = -1; int total = 0; vector<Row> rows; for (int r = 0; r < n; ++r) { int cnt = 0; // number of empty cells int first = n, last = -1; // all empty cells should be in [first, last] for (int c = 0; c < n; ++c) { if (forest[r][c] == 0) { ++total; ++cnt; if (first == n) first = c; last = c; } } // ignore empty rows if (cnt == 0) continue; if (first_row == n) first_row = r; last_row = r; ++cnt_row; // Condition: in each row, there should be only 1 sequence of 0 if (cnt != last - first + 1) return {false, -1}; rows.push_back(Row{first, last}); } // Condition: all rows with empty cells must be consecutive if (cnt_row != last_row - first_row + 1) return {false, -2}; // From biggest row, each row should contains the row next to (& further away from) it int largest_row = min_element(rows.begin(), rows.end()) - rows.begin(); for (int i = largest_row; i > 0; --i) { if (!rows[i].contains(rows[i-1])) return {false, -3}; } for (int i = largest_row; i + 1 < (int) rows.size(); ++i) { if (!rows[i].contains(rows[i+1])) return {false, -4}; } // In decreasing order of size, row should contains next row sort(rows.begin(), rows.end()); for (int i = 0; i + 1 < (int) rows.size(); ++i) { if (!rows[i].contains(rows[i+1])) return {false, -5}; } return {true, total}; } int biggest_stadium(int n, vector<vector<int>> forest) { auto [is_good, cnt] = subtask_25p(n, forest); if (is_good) return cnt; return 0; }
#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...