Submission #841364

#TimeUsernameProblemLanguageResultExecution timeMemory
841364hcngSoccer Stadium (IOI23_soccer)C++17
1.50 / 100
232 ms31764 KiB
#include <bits/stdc++.h> #include "soccer.h" using namespace std; int biggest_stadium(int n, vector<vector<int>> f) { int cnt = 0; vector<pair<int, int>> v; bool flag = false; for (int i = 0; i < n; i++) { int l = -1, r = -1; for (int j = 0; j < n; j++) { if (f[i][j] == 0) cnt++; if (f[i][j] == 0 && l == -1) { l = j; } if (f[i][j] == 0 && r != -1) { return -1; } if (f[i][j] == 1 && l != -1) { r = j - 1; } } if (l != -1 && r == -1) r = n - 1; if (!v.empty() && l == -1) { flag = true; } if (flag && l != -1) { return -1; } if (l != -1) v.emplace_back(l, r); } for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { if ((v[i].first > v[j].first && v[i].second > v[j].second) || (v[i].first < v[j].first && v[i].second < v[j].second)) { return -1; } } } flag = false; for (int i = 1; i < v.size(); i++) { if (!flag) { if (!(v[i].first <= v[i - 1].first && v[i].second >= v[i - 1].first)) { flag = true; } } else { if (!(v[i].first >= v[i - 1].first && v[i].second <= v[i - 1].first)) { return -1; } } } return cnt; }

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
soccer.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for (int j = i + 1; j < v.size(); j++) {
      |                             ~~^~~~~~~~~~
soccer.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 1; i < v.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...