QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506792#5052. Rectangle Flip 2NahidameowWA 288ms5140kbC++201.7kb2024-08-05 22:04:312024-08-05 22:04:32

Judging History

你现在查看的是最新测评结果

  • [2024-08-05 22:04:32]
  • 评测
  • 测评结果:WA
  • 用时:288ms
  • 内存:5140kb
  • [2024-08-05 22:04:31]
  • 提交

answer

#include<bits/stdc++.h>
#define pd push_back
#define all(A) A.begin(),A.end()
#define lb lower_bound
#define ve std::vector
typedef long long ll;
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
namespace Math{
	ll QP(ll x,ll y,ll mod){ll ans=1;for(;y;y>>=1,x=x*x%mod)if(y&1)ans=ans*x%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
const int N=2e5+10;
const int mod=998244353;
void solve(){
	//don't forget to open long long
	int n,m;std::cin>>n>>m;
	ve<ve<int>>L(n+1,ve<int>(m+1,0));
	ve<ve<int>>R(n+1,ve<int>(m+1,m+1));
	ll ans=n*(n+1)/2*m*(m+1)/2;
	for(int i=1;i<=n*m;i++){
		int x,y;std::cin>>x>>y;
		for(int l=x,u1=m+1,d1=0;l>=1&&d1<u1;l--){
			u1=std::min(u1,R[l][y]);
			d1=std::max(d1,L[l][y]);
			for(int r=x,u2=m+1,d2=0;r<=n&&d2<u2;r++){
				u2=std::min(u2,R[r][y]);
				d2=std::max(d2,L[r][y]);
				int d=std::max(d1,d2),u=std::min(u1,u2);
				if(u<=y||d>=y)break;
				ans-=1ll*(u-y)*(y-d);
			}
		}
		for(int j=y;j<=m;j++)
			L[x][j]=std::max(L[x][j],y);
		for(int j=1;j<=y;j++)
			R[x][j]=std::min(R[x][j],y);
		std::cout<<ans<<'\n';
	}
}
int main(){
#ifndef ONLINE_JUDGE
	if(!FileIfstream("IO.in")){
		freopen("IO.in","w",stdout);
		return 0;
	}
	freopen("IO.in","r",stdin);
	freopen("IO.out","w",stdout);
#endif
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int T=1;
	//std::cin>>T;
	while(T--)solve();

#ifndef ONLINE_JUDGE
	std::cerr<<std::fixed<<std::setprecision(10)<<1.0*clock()/CLOCKS_PER_SEC<<'\n';
#endif

	return 0;
}






详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

2 2
1 1
2 1
1 2
2 2

output:

5
3
1
0

result:

ok 4 number(s): "5 3 1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5 5
3 2
2 5
4 3
5 5
2 1
3 5
1 5
3 3
3 4
3 1
4 2
1 4
2 2
4 1
2 3
1 3
5 1
2 4
5 2
4 5
1 1
5 3
4 4
5 4
1 2

output:

153
125
93
84
70
65
60
54
45
42
38
31
26
24
21
18
14
13
10
8
6
4
2
1
0

result:

ok 25 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

5 10
5 4
1 4
3 6
3 5
4 7
5 1
2 9
2 2
3 7
1 2
4 6
2 6
5 5
5 7
5 8
2 7
1 9
5 3
4 3
3 10
4 2
4 9
2 8
3 2
4 1
3 9
4 5
3 1
1 7
5 9
4 8
1 3
2 10
4 4
5 6
1 6
4 10
3 8
5 2
1 5
3 4
1 8
1 1
2 4
2 5
2 3
2 1
1 10
5 10
3 3

output:

685
573
403
378
314
299
243
201
193
189
181
163
156
148
137
133
123
115
97
83
77
68
62
56
52
50
48
45
39
37
35
32
30
27
26
24
22
21
20
18
14
13
11
7
6
4
3
2
1
0

result:

ok 50 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

10 5
6 2
5 4
9 3
9 5
6 1
4 3
10 4
9 1
9 2
3 3
3 2
3 5
5 1
4 4
4 1
2 5
1 5
1 1
7 3
10 1
7 2
1 4
2 4
8 5
7 4
2 1
10 5
1 2
4 5
6 5
6 3
6 4
10 2
1 3
3 4
7 5
8 4
8 2
4 2
8 1
2 2
9 4
5 2
5 5
5 3
3 1
2 3
7 1
10 3
8 3

output:

585
445
375
349
319
259
247
235
229
202
184
160
152
147
142
132
127
118
92
89
85
78
73
62
54
50
49
45
41
35
32
31
29
27
26
25
20
16
14
12
10
9
7
6
5
4
3
2
1
0

result:

ok 50 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

10 10
2 3
4 9
1 6
8 5
9 4
10 4
10 6
3 1
9 5
8 1
7 6
3 8
9 8
2 8
5 8
5 2
8 2
10 8
2 6
1 9
9 7
1 7
5 4
8 3
10 1
10 10
6 1
3 7
3 6
1 4
5 7
3 5
1 10
4 5
7 9
6 2
2 10
2 1
1 1
2 9
7 5
4 7
8 10
5 1
7 1
7 8
4 4
1 3
4 10
6 10
3 3
8 9
8 8
8 6
10 2
2 2
5 5
10 7
9 1
2 4
7 2
5 10
6 8
8 7
2 7
10 5
5 6
1 5
6 7
3 1...

output:

2593
2173
2050
1540
1432
1404
1355
1271
1264
1214
1034
926
856
835
755
642
621
615
585
575
555
546
466
445
439
423
404
378
364
350
334
311
302
277
240
227
217
213
210
208
199
195
178
176
172
164
156
154
146
134
125
119
116
113
109
103
99
98
95
92
89
87
75
72
71
70
66
64
58
56
53
52
49
47
45
44
40
39...

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 4ms
memory: 3624kb

input:

100 100
43 16
47 31
27 79
87 19
43 50
97 58
45 17
99 82
98 16
74 55
62 50
5 4
94 57
56 68
33 19
82 56
43 72
78 36
83 75
82 28
15 27
98 48
89 17
47 68
91 59
54 87
48 32
64 2
60 29
28 68
85 3
99 98
48 79
66 78
53 43
74 58
13 23
64 56
39 4
1 14
47 52
45 99
86 11
68 26
49 18
48 28
87 66
64 58
32 41
84 9...

output:

22110660
19203840
16763688
15856768
13998730
13571914
13518088
13444938
13415162
11803888
11206816
11126216
10988540
10071534
9640344
9425930
9124064
8731358
8438278
8317477
7762957
7735682
7702672
7630852
7562624
7150786
7086362
6999944
6822971
6576482
6546644
6538760
6461388
6285324
6061916
601869...

result:

ok 10000 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1 100
1 60
1 76
1 89
1 77
1 41
1 81
1 42
1 49
1 39
1 37
1 48
1 56
1 26
1 38
1 85
1 50
1 40
1 13
1 20
1 24
1 79
1 21
1 22
1 9
1 92
1 11
1 45
1 58
1 55
1 62
1 69
1 82
1 97
1 67
1 18
1 32
1 88
1 84
1 19
1 96
1 7
1 36
1 83
1 95
1 52
1 98
1 44
1 53
1 12
1 75
1 90
1 87
1 28
1 3
1 1
1 6
1 15
1 65
1 68
1 94...

output:

2590
2190
2034
2022
1243
1211
1193
1116
1038
964
958
930
644
643
627
621
620
451
409
401
397
394
392
356
329
325
316
312
307
279
230
227
207
197
187
157
154
152
151
147
133
129
128
125
119
116
114
112
111
105
103
101
93
81
79
76
70
64
63
61
57
55
54
52
50
49
48
40
37
36
35
34
31
29
28
26
24
23
22
21...

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

100 1
78 1
52 1
95 1
76 1
96 1
49 1
53 1
59 1
77 1
100 1
64 1
11 1
9 1
48 1
15 1
17 1
44 1
46 1
21 1
54 1
39 1
68 1
43 1
4 1
32 1
28 1
73 1
6 1
16 1
62 1
72 1
84 1
65 1
86 1
98 1
75 1
33 1
45 1
25 1
3 1
91 1
82 1
2 1
92 1
63 1
88 1
7 1
50 1
97 1
93 1
14 1
22 1
20 1
42 1
60 1
55 1
80 1
85 1
29 1
34 1...

output:

3256
1904
1802
1754
1749
1602
1579
1477
1476
1472
1412
994
976
939
807
745
637
633
541
536
446
414
410
390
313
285
270
264
263
257
253
187
184
166
162
160
154
153
141
138
118
110
108
105
104
98
96
94
93
91
88
85
82
79
77
73
69
68
65
60
57
54
53
49
47
46
44
42
41
39
38
36
33
31
29
28
26
25
24
23
21
2...

result:

ok 100 numbers

Test #9:

score: -100
Wrong Answer
time: 288ms
memory: 5140kb

input:

500 500
251 452
436 482
88 232
251 447
493 58
197 280
75 489
37 67
63 158
185 93
330 492
262 159
407 19
137 101
352 459
97 149
295 18
309 129
256 445
440 46
486 151
13 147
7 266
22 144
76 408
348 484
118 170
72 355
447 300
343 369
366 293
115 273
424 248
476 384
393 29
457 28
236 252
351 453
385 4
2...

output:

-734610036
-854034536
-2872094888
-2986821138
-3071459378
-4928210082
-4975870482
-5196452679
-5486942918
-6204670986
-6250305243
-7241093149
-7392797300
-7540066196
-7740468115
-7813262699
-7892325431
-8308648103
-8342900785
-8464886973
-8561897735
-8588473479
-8612008207
-8627096905
-8895825419
-8...

result:

wrong answer 1st numbers differ - expected: '14297775500', found: '-734610036'