Submission #1068098

#TimeUsernameProblemLanguageResultExecution timeMemory
1068098pccRectangles (IOI19_rect)C++17
10 / 100
5094 ms67740 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 = sr;i<N;i++)for(int j = sc;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++){ if(good[i][j-1]&&good[i-1][j]&&arr[i][j]<arr[sr][j]&&arr[i][j]<arr[i][sc])good[i][j] = 1; if(!good[i][j])break; row[i][j] = max(row[i][j-1],arr[i][j]); col[i][j] = max(col[i-1][j],arr[i][j]); if(arr[i+1][j]>col[i][j]&&arr[i][j+1]>row[i][j])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...