Submission #1021523

# Submission time Handle Problem Language Result Execution time Memory
1021523 2024-07-12T19:09:38 Z vjudge1 Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 28304 KB
#include "rect.h"
#include <bits/stdc++.h>
#define ll long long
#define mid ((l+r)>>1)
#define pii pair<int,int>
#define fi first
#define se second
#define rep(a,b,c) for(int a=b; a<c; a++)
#define pb push_back

using namespace std;

const int moves[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

ll count_rectangles(vector<vector<int>> a) {
	ll ans=0, n=a.size(), m=a[0].size();
	if(max(n,m)>200){
		queue<int> q;
		int x, y, z, b[4];
		rep(i,0,n){
			rep(j,0,m){
				if(a[i][j]) continue;
				q.push(i);
				q.push(j);
				z=0;
				while(q.size()){
					x=q.front();q.pop();
					y=q.front();q.pop();
					if(a[x][y]) continue;
					a[x][y]=1;
					if(!x || !y || x+1==n || y+1==m) z=-1e9;
					b[1]=max(b[1],x);
					b[0]=min(b[0],x);
					b[3]=max(b[3],y);
					b[2]=min(b[2],y);
					z++;
					rep(k,0,4){
						x+=moves[k][0];
						y+=moves[k][1];
						if(0<=x && x<n && 0<=y && y<m && !a[i][j]){
							q.push(x);
							q.push(y);
						}
						x-=moves[k][0];
						y-=moves[k][1];
					}
				}
				if((b[1]-b[0]+1)*(b[3]-b[2]+1)==z) ans+=z; 
			}
		}
	}
	rep(ri,1,n-1){
		rep(ci,1,m-1){
			rep(rf,ri,n-1){
				rep(cf,ci,m-1){
					bool rect=1;
					rep(i,ri,rf+1){
						rep(j,ci,cf+1){
					if(a[i][j]>=a[ri-1][j] || a[i][j]>=a[rf+1][j] || a[i][j]>=a[i][ci-1] || a[i][j]>=a[i][cf+1]){
								rect=false;
								break;
							}
						}
						if(!rect) break;
					}
					ans+=rect;
				}
			}
		}
	}
	return ans;
}

Compilation message

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:48:27: warning: 'b[3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     if((b[1]-b[0]+1)*(b[3]-b[2]+1)==z) ans+=z;
      |                       ~~~~^~~~~
rect.cpp:48:27: warning: 'b[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
rect.cpp:48:13: warning: 'b[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     if((b[1]-b[0]+1)*(b[3]-b[2]+1)==z) ans+=z;
      |         ~~~~^~~~~
rect.cpp:48:13: warning: 'b[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 45 ms 344 KB Output is correct
23 Correct 35 ms 348 KB Output is correct
24 Correct 35 ms 600 KB Output is correct
25 Correct 22 ms 344 KB Output is correct
26 Correct 25 ms 348 KB Output is correct
27 Correct 24 ms 348 KB Output is correct
28 Correct 25 ms 348 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 45 ms 344 KB Output is correct
18 Correct 35 ms 348 KB Output is correct
19 Correct 35 ms 600 KB Output is correct
20 Correct 22 ms 344 KB Output is correct
21 Correct 25 ms 348 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 25 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1365 ms 968 KB Output is correct
31 Correct 1396 ms 960 KB Output is correct
32 Correct 1334 ms 1104 KB Output is correct
33 Correct 855 ms 812 KB Output is correct
34 Correct 967 ms 880 KB Output is correct
35 Correct 1002 ms 1040 KB Output is correct
36 Correct 942 ms 1000 KB Output is correct
37 Correct 912 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 45 ms 344 KB Output is correct
18 Correct 35 ms 348 KB Output is correct
19 Correct 35 ms 600 KB Output is correct
20 Correct 22 ms 344 KB Output is correct
21 Correct 25 ms 348 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 25 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1365 ms 968 KB Output is correct
26 Correct 1396 ms 960 KB Output is correct
27 Correct 1334 ms 1104 KB Output is correct
28 Correct 855 ms 812 KB Output is correct
29 Correct 967 ms 880 KB Output is correct
30 Correct 1002 ms 1040 KB Output is correct
31 Correct 942 ms 1000 KB Output is correct
32 Correct 912 ms 1028 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Execution timed out 5047 ms 7260 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 348 KB Output is correct
2 Correct 9 ms 544 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 348 KB Output is correct
6 Correct 10 ms 552 KB Output is correct
7 Correct 9 ms 556 KB Output is correct
8 Correct 9 ms 500 KB Output is correct
9 Correct 9 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Execution timed out 5082 ms 28304 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 45 ms 344 KB Output is correct
18 Correct 35 ms 348 KB Output is correct
19 Correct 35 ms 600 KB Output is correct
20 Correct 22 ms 344 KB Output is correct
21 Correct 25 ms 348 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 25 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1365 ms 968 KB Output is correct
26 Correct 1396 ms 960 KB Output is correct
27 Correct 1334 ms 1104 KB Output is correct
28 Correct 855 ms 812 KB Output is correct
29 Correct 967 ms 880 KB Output is correct
30 Correct 1002 ms 1040 KB Output is correct
31 Correct 942 ms 1000 KB Output is correct
32 Correct 912 ms 1028 KB Output is correct
33 Execution timed out 5047 ms 7260 KB Time limit exceeded
34 Halted 0 ms 0 KB -