Submission #1068107

#TimeUsernameProblemLanguageResultExecution timeMemory
1068107pccRectangles (IOI19_rect)C++17
10 / 100
5049 ms67920 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; #define ll long long int N,M; vector<vector<int>> good,row,col,arr; ll calc(int sr,int sc){ //cerr<<sr<<','<<sc<<endl; for(int i = 0;i<N;i++)for(int j = 0;j<M;j++)good[i][j] = col[i][j] = row[i][j] = 0; for(int i = 0;i<N;i++)good[i][sc] = 1; for(int i = 0;i<M;i++)good[sr][i] = 1; ll re = 0; for(int i = sr+1;i+1<N;i++){ for(int j = sc+1;j+1<M;j++){ row[i][j] = max(row[i][j-1],arr[i][j]); col[i][j] = max(col[i-1][j],arr[i][j]); good[i][j] = true; if(!good[i][j-1]||!good[i-1][j])good[i][j] = false; if(row[i][j]>=arr[i][sc]||col[i][j]>=arr[sr][j]){ good[i][j] = false; } if(!good[i][j])break; if(arr[i+1][j]>col[i][j]&&arr[i][j+1]>row[i][j]){ /* cerr<<"FOUND: "<<sr+1<<' '<<sc+1<<','<<i<<' '<<j<<endl; cerr<<arr[i][j]<<','<<col[i][j]<<','<<row[i][j]<<endl; */ re++; } if(arr[i+1][j]<=col[i][j])break; } } return re; } long long count_rectangles(std::vector<std::vector<int> > a) { N = a.size(),M = a[0].size(); row = col = good = vector<vector<int>>(N,vector<int>(M,0)); arr = a; ll ans = 0; for(int i = 0;i+1<N;i++){ for(int j = 0;j+1<M;j++){ ans += calc(i,j); } } 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...