Submission #1021511

# Submission time Handle Problem Language Result Execution time Memory
1021511 2024-07-12T19:04:46 Z vjudge1 Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 28416 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();
					a[i][j]=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);
						}
					}
				}
				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:19:16: warning: 'b[3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |   int x, y, z, b[4];
      |                ^
rect.cpp:19:16: warning: 'b[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
rect.cpp:19:16: warning: 'b[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
rect.cpp:19:16: warning: 'b[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 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 348 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 428 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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 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 348 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 428 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 43 ms 504 KB Output is correct
23 Correct 35 ms 344 KB Output is correct
24 Correct 48 ms 348 KB Output is correct
25 Correct 22 ms 500 KB Output is correct
26 Correct 24 ms 348 KB Output is correct
27 Correct 25 ms 344 KB Output is correct
28 Correct 31 ms 484 KB Output is correct
29 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 43 ms 504 KB Output is correct
18 Correct 35 ms 344 KB Output is correct
19 Correct 48 ms 348 KB Output is correct
20 Correct 22 ms 500 KB Output is correct
21 Correct 24 ms 348 KB Output is correct
22 Correct 25 ms 344 KB Output is correct
23 Correct 31 ms 484 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 428 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 1413 ms 856 KB Output is correct
31 Correct 1354 ms 856 KB Output is correct
32 Correct 1348 ms 1040 KB Output is correct
33 Correct 828 ms 600 KB Output is correct
34 Correct 963 ms 872 KB Output is correct
35 Correct 957 ms 860 KB Output is correct
36 Correct 993 ms 1104 KB Output is correct
37 Correct 921 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 43 ms 504 KB Output is correct
18 Correct 35 ms 344 KB Output is correct
19 Correct 48 ms 348 KB Output is correct
20 Correct 22 ms 500 KB Output is correct
21 Correct 24 ms 348 KB Output is correct
22 Correct 25 ms 344 KB Output is correct
23 Correct 31 ms 484 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 1413 ms 856 KB Output is correct
26 Correct 1354 ms 856 KB Output is correct
27 Correct 1348 ms 1040 KB Output is correct
28 Correct 828 ms 600 KB Output is correct
29 Correct 963 ms 872 KB Output is correct
30 Correct 957 ms 860 KB Output is correct
31 Correct 993 ms 1104 KB Output is correct
32 Correct 921 ms 1032 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 428 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 5087 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 348 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 9 ms 548 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
7 Correct 9 ms 524 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 9 ms 560 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 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 428 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 348 KB Output is correct
7 Execution timed out 5083 ms 28416 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 444 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 43 ms 504 KB Output is correct
18 Correct 35 ms 344 KB Output is correct
19 Correct 48 ms 348 KB Output is correct
20 Correct 22 ms 500 KB Output is correct
21 Correct 24 ms 348 KB Output is correct
22 Correct 25 ms 344 KB Output is correct
23 Correct 31 ms 484 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 1413 ms 856 KB Output is correct
26 Correct 1354 ms 856 KB Output is correct
27 Correct 1348 ms 1040 KB Output is correct
28 Correct 828 ms 600 KB Output is correct
29 Correct 963 ms 872 KB Output is correct
30 Correct 957 ms 860 KB Output is correct
31 Correct 993 ms 1104 KB Output is correct
32 Correct 921 ms 1032 KB Output is correct
33 Execution timed out 5087 ms 7260 KB Time limit exceeded
34 Halted 0 ms 0 KB -