Submission #840445

#TimeUsernameProblemLanguageResultExecution timeMemory
840445mohammad_kilaniSoccer Stadium (IOI23_soccer)C++17
1.50 / 100
259 ms31760 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; int biggest_stadium(int N, std::vector<std::vector<int>> F){ vector< pair< int , int > > v; for(int cnt , has = 0, i = 0 ;i < N;i++){ cnt = 0; has = 0; for(int j = 0 ;j < N;j++){ if(F[i][j] == 0){ cnt++; } else{ if(cnt == 0) continue; has++; v.push_back(make_pair(cnt , j - 1)); cnt = 0; } } if(cnt > 0){ has++; v.push_back(make_pair(cnt , N - 1)); } if(has > 1) return 0; if(has == 0) v.push_back(make_pair(0 , N - 1)); } int state = 0; for(int i = 1;i < N;i++){ if(v[i].first < v[i - 1].first){ if(state == 1) return false; state = 1; } } sort(v.begin(),v.end()); int ans = 0; for(int i = 0 ;i < (int)v.size();i++){ ans += v[i].first; v[i].first = v[i].second - v[i].first + 1; if(i == 0) continue; if(v[i - 1].second < v[i - 1].first) continue; if(v[i - 1].first < v[i].first || v[i - 1].second > v[i].second) return 0; } return ans; }
#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...