답안 #1060137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060137 2024-08-15T10:55:50 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++;
			}
			while(!s.empty())s.pop();
			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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 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 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 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 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 4 ms 520 KB Output is correct
24 Correct 4 ms 348 KB Output is correct
25 Correct 6 ms 508 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 9 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 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 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 520 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 6 ms 508 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
23 Correct 9 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 70 ms 904 KB Output is correct
31 Correct 61 ms 860 KB Output is correct
32 Correct 62 ms 860 KB Output is correct
33 Correct 101 ms 860 KB Output is correct
34 Correct 114 ms 900 KB Output is correct
35 Correct 113 ms 856 KB Output is correct
36 Correct 106 ms 856 KB Output is correct
37 Correct 107 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 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 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 520 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 6 ms 508 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
23 Correct 9 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 70 ms 904 KB Output is correct
26 Correct 61 ms 860 KB Output is correct
27 Correct 62 ms 860 KB Output is correct
28 Correct 101 ms 860 KB Output is correct
29 Correct 114 ms 900 KB Output is correct
30 Correct 113 ms 856 KB Output is correct
31 Correct 106 ms 856 KB Output is correct
32 Correct 107 ms 856 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2709 ms 6236 KB Output is correct
39 Correct 2498 ms 6248 KB Output is correct
40 Correct 2506 ms 6232 KB Output is correct
41 Correct 2448 ms 6256 KB Output is correct
42 Correct 3051 ms 6256 KB Output is correct
43 Correct 3088 ms 6256 KB Output is correct
44 Correct 3079 ms 6252 KB Output is correct
45 Correct 3139 ms 5880 KB Output is correct
46 Correct 4261 ms 6244 KB Output is correct
47 Execution timed out 5062 ms 6484 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 348 KB Output is correct
2 Correct 125 ms 468 KB Output is correct
3 Correct 184 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 201 ms 348 KB Output is correct
6 Correct 218 ms 472 KB Output is correct
7 Correct 219 ms 468 KB Output is correct
8 Correct 205 ms 348 KB Output is correct
9 Correct 221 ms 344 KB Output is correct
10 Correct 136 ms 348 KB Output is correct
11 Correct 146 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Execution timed out 5087 ms 28928 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 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 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 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 520 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 6 ms 508 KB Output is correct
21 Correct 7 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
23 Correct 9 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 70 ms 904 KB Output is correct
26 Correct 61 ms 860 KB Output is correct
27 Correct 62 ms 860 KB Output is correct
28 Correct 101 ms 860 KB Output is correct
29 Correct 114 ms 900 KB Output is correct
30 Correct 113 ms 856 KB Output is correct
31 Correct 106 ms 856 KB Output is correct
32 Correct 107 ms 856 KB Output is correct
33 Correct 2709 ms 6236 KB Output is correct
34 Correct 2498 ms 6248 KB Output is correct
35 Correct 2506 ms 6232 KB Output is correct
36 Correct 2448 ms 6256 KB Output is correct
37 Correct 3051 ms 6256 KB Output is correct
38 Correct 3088 ms 6256 KB Output is correct
39 Correct 3079 ms 6252 KB Output is correct
40 Correct 3139 ms 5880 KB Output is correct
41 Correct 4261 ms 6244 KB Output is correct
42 Execution timed out 5062 ms 6484 KB Time limit exceeded
43 Halted 0 ms 0 KB -