Submission #1021118

# Submission time Handle Problem Language Result Execution time Memory
1021118 2024-07-12T14:17:56 Z Malix Rectangles (IOI19_rect) C++14
50 / 100
5000 ms 61728 KB
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))

ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

long long count_rectangles(std::vector<std::vector<int> > a) {
	bool flag=1;
	int n=a.size();
	int m=a[0].size();
	REP(i,0,n)REP(j,0,m)if(a[i][j]>1)flag=0;
if(flag){
	ll ans=0;
	queue<pi> pq;
	REP(i,1,n-1)REP(j,1,m-1){
		if(a[i][j]==1)continue;
		int c=0,d=0;
		while(j+c<m-1&&a[i][j+c]==0)c++;
		while(i+d<n-1&&a[i+d][j]==0)d++;
		bool g=1;
		REP(x,i,i+d){
			if(a[x][j-1]==0||a[x][j+c]==0)g=0;
		}
		REP(x,j,j+c){
			if(a[i-1][x]==0||a[i+d][x]==0)g=0;
		}
		pq.push({i,j});int k=0;
		while(!pq.empty()){
			int x=pq.front().F;
			int y=pq.front().S;
			pq.pop();
			if(a[x][y]==1)continue;
			a[x][y]=1;k++;
			if(x+1<n-1&&a[x+1][y]==0)pq.push({x+1,y});
			if(x-1>0&&a[x-1][y]==0)pq.push({x-1,y});
			if(y-1>0&&a[x][y-1]==0)pq.push({x,y-1});
			if(y+1<m-1&&a[x][y+1]==0)pq.push({x,y+1});
		}
		if(k==c*d&&g)ans++;
	}
	return ans;
}
	vii b(n,vi(m,0)),c(n,vi(m,0));
	ll ans=0;
	REP(i,1,n-1)REP(j,1,m-1){
		vii top(n,vi(m,0)),left(n,vi(m,0)),d(n,vi(m,0));
		REP(x,i,n-1)REP(y,j,m-1){
			top[x][y]=max(top[x-1][y],a[x][y]);
			left[x][y]=max(left[x][y-1],a[x][y]);
		}
		REP(y,j,m-1)d[i-1][y]=1;
		REP(x,i,n-1)REP(y,j,m-1)if(left[x][y]<a[x][j-1]&&left[x][y]<a[x][y+1]&&d[x-1][y])d[x][y]=1;
		REP(x,i,n-1){
			REP(y,j,m-1){
				if(top[x][y]>=a[i-1][y]||top[x][y]>=a[x+1][y])break;
				if(d[x][y]){
					ans++;//cerr<<i<<" "<<j<<" "<<x<<" "<<y<<"\n";
				}
			}
		}
		// if(i==n-2&&j==m-2){cout<<"\n";
		// 	REP(x,i,n-1){
		// 		REP(y,j,m-1)cout<<d[x][y]<<" ";
		// 	cout<<"\n";
		// 	}
		// }
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 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 4 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 460 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 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 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 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 4 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 460 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 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 81 ms 604 KB Output is correct
23 Correct 80 ms 440 KB Output is correct
24 Correct 77 ms 600 KB Output is correct
25 Correct 78 ms 604 KB Output is correct
26 Correct 97 ms 624 KB Output is correct
27 Correct 101 ms 604 KB Output is correct
28 Correct 80 ms 604 KB Output is correct
29 Correct 39 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 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 4 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 460 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 81 ms 604 KB Output is correct
18 Correct 80 ms 440 KB Output is correct
19 Correct 77 ms 600 KB Output is correct
20 Correct 78 ms 604 KB Output is correct
21 Correct 97 ms 624 KB Output is correct
22 Correct 101 ms 604 KB Output is correct
23 Correct 80 ms 604 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 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 2767 ms 2000 KB Output is correct
31 Correct 2740 ms 2036 KB Output is correct
32 Correct 2775 ms 1884 KB Output is correct
33 Correct 2922 ms 1680 KB Output is correct
34 Correct 2898 ms 1732 KB Output is correct
35 Correct 2903 ms 2072 KB Output is correct
36 Correct 2857 ms 1852 KB Output is correct
37 Correct 2574 ms 1860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 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 4 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 460 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 81 ms 604 KB Output is correct
18 Correct 80 ms 440 KB Output is correct
19 Correct 77 ms 600 KB Output is correct
20 Correct 78 ms 604 KB Output is correct
21 Correct 97 ms 624 KB Output is correct
22 Correct 101 ms 604 KB Output is correct
23 Correct 80 ms 604 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 2767 ms 2000 KB Output is correct
26 Correct 2740 ms 2036 KB Output is correct
27 Correct 2775 ms 1884 KB Output is correct
28 Correct 2922 ms 1680 KB Output is correct
29 Correct 2898 ms 1732 KB Output is correct
30 Correct 2903 ms 2072 KB Output is correct
31 Correct 2857 ms 1852 KB Output is correct
32 Correct 2574 ms 1860 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 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 5020 ms 17572 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 656 KB Output is correct
2 Correct 12 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 604 KB Output is correct
6 Correct 14 ms 656 KB Output is correct
7 Correct 14 ms 604 KB Output is correct
8 Correct 14 ms 604 KB Output is correct
9 Correct 14 ms 604 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 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 1 ms 348 KB Output is correct
7 Correct 86 ms 28504 KB Output is correct
8 Correct 176 ms 61324 KB Output is correct
9 Correct 195 ms 61520 KB Output is correct
10 Correct 180 ms 61728 KB Output is correct
11 Correct 97 ms 30544 KB Output is correct
12 Correct 183 ms 57744 KB Output is correct
13 Correct 204 ms 61560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 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 4 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 460 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 81 ms 604 KB Output is correct
18 Correct 80 ms 440 KB Output is correct
19 Correct 77 ms 600 KB Output is correct
20 Correct 78 ms 604 KB Output is correct
21 Correct 97 ms 624 KB Output is correct
22 Correct 101 ms 604 KB Output is correct
23 Correct 80 ms 604 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 2767 ms 2000 KB Output is correct
26 Correct 2740 ms 2036 KB Output is correct
27 Correct 2775 ms 1884 KB Output is correct
28 Correct 2922 ms 1680 KB Output is correct
29 Correct 2898 ms 1732 KB Output is correct
30 Correct 2903 ms 2072 KB Output is correct
31 Correct 2857 ms 1852 KB Output is correct
32 Correct 2574 ms 1860 KB Output is correct
33 Execution timed out 5020 ms 17572 KB Time limit exceeded
34 Halted 0 ms 0 KB -