Submission #1060141

# Submission time Handle Problem Language Result Execution time Memory
1060141 2024-08-15T10:57:41 Z Unforgettablepl Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 28928 KB
#pragma GCC optimize("Ofast","unroll-all-loops")
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;


long long count_rectangles(vector<vector<int>> a){
	int n = a.size();
	int m = a[0].size();
	long long ans = 0;
	for(int i=0;i<m;i++) {
		vector<int> maxi(n);
		vector allowedranges(n,vector(n,0));
		for(int j=i+1;j<m-1;j++) {
			stack<pair<int,int>> s;
			int last_voilater = -1;
			for(int k=0;k<n;k++) {
				maxi[k]=max(maxi[k],a[k][j]);
				if(k!=0 and (maxi[k-1]>=a[k-1][i] or maxi[k-1]>=a[k-1][j+1]))last_voilater=k-1;
				while(!s.empty() and s.top().first<a[k][j])s.pop();
				if(s.empty()) {
					s.emplace(a[k][j],k);
					continue;
				}
				const int l = s.top().second;
				s.emplace(a[k][j],k);
				const int r = k;
				if(r==l+1)continue;
				allowedranges[l][r]++;
				if(l<last_voilater)continue;
				if(allowedranges[l][r]==j-i)ans++;
			}
			s = stack<pair<int,int>>();
			last_voilater = n;
			for(int k=n-1;k>=0;k--) {
				if(k!=n-1 and (maxi[k+1]>=a[k+1][i] or maxi[k+1]>=a[k+1][j+1]))last_voilater=k+1;
				while(!s.empty() and s.top().first<a[k][j])s.pop();
				if(s.empty() or s.top().first==a[k][j]) {
					s.emplace(a[k][j],k);
					continue;
				}
				const int r = s.top().second;
				s.emplace(a[k][j],k);
				const int l = k;
				if(r==l+1)continue;
				allowedranges[l][r]++;
				if(last_voilater<r)continue;
				if(allowedranges[l][r]==j-i)ans++;
			}
		}
	}
	return ans;
}
# 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 348 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 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 0 ms 348 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 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 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 4 ms 348 KB Output is correct
23 Correct 5 ms 348 KB Output is correct
24 Correct 4 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 7 ms 516 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 2 ms 492 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 348 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 516 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 0 ms 344 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 65 ms 860 KB Output is correct
31 Correct 61 ms 904 KB Output is correct
32 Correct 60 ms 900 KB Output is correct
33 Correct 103 ms 900 KB Output is correct
34 Correct 111 ms 856 KB Output is correct
35 Correct 115 ms 856 KB Output is correct
36 Correct 109 ms 900 KB Output is correct
37 Correct 107 ms 888 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 348 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 516 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 65 ms 860 KB Output is correct
26 Correct 61 ms 904 KB Output is correct
27 Correct 60 ms 900 KB Output is correct
28 Correct 103 ms 900 KB Output is correct
29 Correct 111 ms 856 KB Output is correct
30 Correct 115 ms 856 KB Output is correct
31 Correct 109 ms 900 KB Output is correct
32 Correct 107 ms 888 KB Output is correct
33 Correct 0 ms 344 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 Correct 2726 ms 6252 KB Output is correct
39 Correct 2528 ms 6256 KB Output is correct
40 Correct 2477 ms 6212 KB Output is correct
41 Correct 2396 ms 6252 KB Output is correct
42 Correct 2946 ms 6272 KB Output is correct
43 Correct 2894 ms 6256 KB Output is correct
44 Correct 2879 ms 6252 KB Output is correct
45 Correct 3007 ms 5744 KB Output is correct
46 Correct 3910 ms 6232 KB Output is correct
47 Correct 4369 ms 6248 KB Output is correct
48 Execution timed out 5033 ms 6288 KB Time limit exceeded
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 257 ms 348 KB Output is correct
2 Correct 182 ms 464 KB Output is correct
3 Correct 244 ms 468 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 296 ms 480 KB Output is correct
6 Correct 300 ms 468 KB Output is correct
7 Correct 294 ms 344 KB Output is correct
8 Correct 295 ms 596 KB Output is correct
9 Correct 282 ms 348 KB Output is correct
10 Correct 176 ms 348 KB Output is correct
11 Correct 237 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
7 Execution timed out 5084 ms 28928 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 348 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 516 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 65 ms 860 KB Output is correct
26 Correct 61 ms 904 KB Output is correct
27 Correct 60 ms 900 KB Output is correct
28 Correct 103 ms 900 KB Output is correct
29 Correct 111 ms 856 KB Output is correct
30 Correct 115 ms 856 KB Output is correct
31 Correct 109 ms 900 KB Output is correct
32 Correct 107 ms 888 KB Output is correct
33 Correct 2726 ms 6252 KB Output is correct
34 Correct 2528 ms 6256 KB Output is correct
35 Correct 2477 ms 6212 KB Output is correct
36 Correct 2396 ms 6252 KB Output is correct
37 Correct 2946 ms 6272 KB Output is correct
38 Correct 2894 ms 6256 KB Output is correct
39 Correct 2879 ms 6252 KB Output is correct
40 Correct 3007 ms 5744 KB Output is correct
41 Correct 3910 ms 6232 KB Output is correct
42 Correct 4369 ms 6248 KB Output is correct
43 Execution timed out 5033 ms 6288 KB Time limit exceeded
44 Halted 0 ms 0 KB -