Submission #1000747

#TimeUsernameProblemLanguageResultExecution timeMemory
1000747kunzaZa183Soccer Stadium (IOI23_soccer)C++17
1.50 / 100
208 ms39044 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; int biggest_stadium(int N, vector<vector<int>> F) { vector<pair<int, int>> vpii; int cur; for (int i = 0; i < N; i++) { pair<int, int> pii = {-1, -1}; cur = 0; for (int j = 0; j < N; j++) if (cur == 0) { if (F[i][j] == 0) { cur++; pii.first = j; } } else if (cur == 1) { if (F[i][j] == 1) { cur++; pii.second = j - 1; } } else if (cur == 2) if (F[i][j] == 0) return INT_MAX; if (cur == 1) pii.second = N - 1; vpii.push_back(pii); } // for (auto a : vpii) cout << a.first << " " << a.second << "\n"; cur = 0; for (auto a : vpii) if (cur == 0) { if (a.first != -1) cur++; } else if (cur == 1) { if (a.first == -1) cur++; } else if (cur == 2) { if (a.first != -1) return INT_MAX; } while (!vpii.empty()) if (vpii.back().first == -1) vpii.pop_back(); else break; while (!vpii.empty()) if (vpii.front().first == -1) vpii.erase(vpii.begin()); else break; for (int i = 0; i < vpii.size(); i++) { bool fails = 0; for (int j = i - 1; j >= 0; j--) if (vpii[j].first < vpii[j + 1].first || vpii[j].second > vpii[j + 1].second) fails = 1; for (int j = i + 1; j < vpii.size(); j++) if (vpii[j].first < vpii[j - 1].first || vpii[j].second > vpii[j - 1].second) fails = 1; if (!fails) goto A; } return INT_MAX; A:; vpii.clear(); for (int j = 0; j < N; j++) { pair<int, int> pii = {-1, -1}; cur = 0; for (int i = 0; i < N; i++) if (cur == 0) { if (F[i][j] == 0) { cur++; pii.first = i; } } else if (cur == 1) { if (F[i][j] == 1) { cur++; pii.second = i - 1; } } else if (cur == 2) if (F[i][j] == 0) return INT_MAX; if (cur == 1) pii.second = N - 1; vpii.push_back(pii); } // for (auto a : vpii) cout << a.first << " " << a.second << '\n'; cur = 0; for (auto a : vpii) if (cur == 0) { if (a.first != -1) cur++; } else if (cur == 1) { if (a.first == -1) cur++; } else if (cur == 2) { if (a.first != -1) return INT_MAX; } while (!vpii.empty()) if (vpii.back().first == -1) vpii.pop_back(); else break; while (!vpii.empty()) if (vpii.front().first == -1) vpii.erase(vpii.begin()); else break; for (int i = 0; i < vpii.size(); i++) { bool fails = 0; for (int j = i - 1; j >= 0; j--) if (vpii[j].first < vpii[j + 1].first || vpii[j].second > vpii[j + 1].second) fails = 1; for (int j = i + 1; j < vpii.size(); j++) if (vpii[j].first < vpii[j - 1].first || vpii[j].second > vpii[j - 1].second) fails = 1; if (!fails) { int ct = 0; for (auto a : F) for (auto b : a) ct += 1 - b; return ct; } } return INT_MAX; }

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for (int i = 0; i < vpii.size(); i++) {
      |                   ~~^~~~~~~~~~~~~
soccer.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int j = i + 1; j < vpii.size(); j++)
      |                         ~~^~~~~~~~~~~~~
soccer.cpp:102:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |   for (int i = 0; i < vpii.size(); i++) {
      |                   ~~^~~~~~~~~~~~~
soccer.cpp:108:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |     for (int j = i + 1; j < vpii.size(); j++)
      |                         ~~^~~~~~~~~~~~~
#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...