# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1068107 |
2024-08-21T07:44:06 Z |
pcc |
Rectangles (IOI19_rect) |
C++17 |
|
5000 ms |
67920 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
604 KB |
Output is correct |
2 |
Correct |
46 ms |
348 KB |
Output is correct |
3 |
Correct |
43 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
45 ms |
604 KB |
Output is correct |
6 |
Correct |
43 ms |
600 KB |
Output is correct |
7 |
Correct |
43 ms |
600 KB |
Output is correct |
8 |
Correct |
42 ms |
608 KB |
Output is correct |
9 |
Correct |
48 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
15 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
5049 ms |
67920 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |