Submission #1008161

#TimeUsernameProblemLanguageResultExecution timeMemory
1008161AmrSoccer Stadium (IOI23_soccer)C++17
12 / 100
4567 ms183772 KiB
#include "soccer.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; using namespace std; #define F first #define S second #define sz size() #define all(x) (x).begin(), (x).end() const int N = 2002; ll n; vector<vector<int> > a; ll prer[N][N], pred[N][N]; ll best = 0; bool good() { vector<pair<ll,ll> > m; // for(int i = 0; i <= n; i++) pre[i][0] = pre[0][i] = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { prer[i][j] = prer[i][j-1]+(a[i-1][j-1]==2); } } for(int j = 1; j <= n; j++) { for(int i = 1; i <= n; i++) { pred[i][j] = pred[i-1][j]+(a[i-1][j-1]==2); } } for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(a[i][j]==2) m.push_back({i,j}); for(int i = 0; i < m.sz; i++) { for(int j = i+1; j < m.sz; j++) { ll x1 = m[i].F , y1 = m[i].S , x2 = m[j].F , y2 = m[j].S; x1++,y1++,x2++,y2++; //if(mm) //cout << x1 << " " << x2 << endl; ll cnt = pred[x2-1][y1]-pred[x1-1][y1]; if(y1<=y2) { cnt += prer[x2][y2]-prer[x2][y1-1]; } else if(y1>y2) { cnt+=prer[x2][y1]-prer[x2][y2-1]; } //if(mm) cout << i << " " << j << " " << cnt << endl; ll cnt2 = pred[x2-1][y2]-pred[x1-1][y2]; if(y1<=y2) { cnt2+= prer[x1][y2]-prer[x1][y1-1]; } else { cnt2+=prer[x1][y1]-prer[x1][y2-1]; } if((cnt==x2-x1+abs(y1-y2)+1)||(cnt2==x2-x1+abs(y1-y2)+1)) {} else return 0; } } return 1; } int biggest_stadium(int N, std::vector<std::vector<int>> F) { best = 0; n = N, a = F; ll num = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(a[i][j]==0) a[i][j] = 2,num++; if(good()) return num; else return 0; }

Compilation message (stderr)

soccer.cpp: In function 'bool good()':
soccer.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < m.sz; i++)
      |                      ^
soccer.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j = i+1; j < m.sz; 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...