Submission #1021519

# Submission time Handle Problem Language Result Execution time Memory
1021519 2024-07-12T19:07:10 Z vjudge1 Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 28436 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[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: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 1 ms 344 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 688 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 688 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 40 ms 444 KB Output is correct
23 Correct 40 ms 348 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 26 ms 500 KB Output is correct
26 Correct 24 ms 508 KB Output is correct
27 Correct 24 ms 348 KB Output is correct
28 Correct 31 ms 508 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 40 ms 444 KB Output is correct
18 Correct 40 ms 348 KB Output is correct
19 Correct 39 ms 348 KB Output is correct
20 Correct 26 ms 500 KB Output is correct
21 Correct 24 ms 508 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 31 ms 508 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 688 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1415 ms 860 KB Output is correct
31 Correct 1502 ms 964 KB Output is correct
32 Correct 1333 ms 1032 KB Output is correct
33 Correct 882 ms 604 KB Output is correct
34 Correct 983 ms 856 KB Output is correct
35 Correct 955 ms 1104 KB Output is correct
36 Correct 997 ms 860 KB Output is correct
37 Correct 927 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 40 ms 444 KB Output is correct
18 Correct 40 ms 348 KB Output is correct
19 Correct 39 ms 348 KB Output is correct
20 Correct 26 ms 500 KB Output is correct
21 Correct 24 ms 508 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 31 ms 508 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1415 ms 860 KB Output is correct
26 Correct 1502 ms 964 KB Output is correct
27 Correct 1333 ms 1032 KB Output is correct
28 Correct 882 ms 604 KB Output is correct
29 Correct 983 ms 856 KB Output is correct
30 Correct 955 ms 1104 KB Output is correct
31 Correct 997 ms 860 KB Output is correct
32 Correct 927 ms 1028 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 688 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Execution timed out 5028 ms 7256 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 344 KB Output is correct
2 Correct 9 ms 536 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 9 ms 348 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
7 Correct 9 ms 552 KB Output is correct
8 Correct 9 ms 532 KB Output is correct
9 Correct 9 ms 600 KB Output is correct
10 Correct 0 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 1 ms 344 KB Output is correct
3 Correct 1 ms 688 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Execution timed out 5080 ms 28436 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 40 ms 444 KB Output is correct
18 Correct 40 ms 348 KB Output is correct
19 Correct 39 ms 348 KB Output is correct
20 Correct 26 ms 500 KB Output is correct
21 Correct 24 ms 508 KB Output is correct
22 Correct 24 ms 348 KB Output is correct
23 Correct 31 ms 508 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 1415 ms 860 KB Output is correct
26 Correct 1502 ms 964 KB Output is correct
27 Correct 1333 ms 1032 KB Output is correct
28 Correct 882 ms 604 KB Output is correct
29 Correct 983 ms 856 KB Output is correct
30 Correct 955 ms 1104 KB Output is correct
31 Correct 997 ms 860 KB Output is correct
32 Correct 927 ms 1028 KB Output is correct
33 Execution timed out 5028 ms 7256 KB Time limit exceeded
34 Halted 0 ms 0 KB -