QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354995#3873. Towersstrcmp11 512ms158972kbC++141.5kb2024-03-16 10:29:022024-03-16 10:29:03

Judging History

This is the latest submission verdict.

  • [2024-03-16 10:29:03]
  • Judged
  • Verdict: 11
  • Time: 512ms
  • Memory: 158972kb
  • [2024-03-16 10:29:02]
  • Submitted

answer

#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
using ld = double;
typedef long long int ll;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using uint = unsigned int;
const int maxn = 1e6 + 10;
const ll inf = 114514191981052013LL;
const int mod = 1e9 + 7;
int n, p = 0, l[maxn], r[maxn], ans[maxn], q[maxn << 2], hd = 1, tl = 0;
struct Node { int x, y; } c[maxn]; set<int>s[maxn]; vector<int>f[maxn], t;
inline int cmp(int i, int j) { return c[i].x > c[j].x; }
inline void ins(int x) { ans[x] = 1; s[c[x].x].insert(c[x].y); if (s[c[x].x].size() > 2) q[++tl] = c[x].x; }
inline void del(int x) { ans[x] = 0; s[c[x].x].erase(c[x].y); }
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &c[i].x, &c[i].y), f[c[i].y].push_back(i);
	for (int i = 1; i < maxn; i++) {
		if (f[i].empty()) continue;
		l[i] = 0, r[i] = f[i].size() - 1;
		sort(f[i].begin(), f[i].end(), cmp); ins(f[i][0]);
		if (f[i].size() > 1) ins(f[i].back());
	}
	while (hd <= tl) {
		int x = q[hd++];
		if (s[x].size() < 3) continue;
		int mi = *s[x].begin(), mx = *--s[x].end(); t.clear();
		for (auto i : s[x]) if (i != mi && i != mx) t.push_back(i);
		for (auto i : t) {
			int u = f[i][l[i]], v = f[i][r[i]];
			if (l[i] == r[i]) del(u), ++l[i];
			else if (x == c[u].x) {
				del(u), ++l[i];
				if (l[i] != r[i]) ins(f[i][l[i]]);
			}
			else if (x == c[v].x) {
				del(u), --r[i];
				if (l[i] != r[i]) ins(f[i][r[i]]);
			}
		}
	}
	for (int i = 1; i <= n; i++) printf("%d", ans[i]); puts("");
	return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 11ms
memory: 85428kb

input:

2
869400 218695
664808 31410

output:

11

result:

ok 

Test #2:

score: 0
Accepted
time: 11ms
memory: 80756kb

input:

2
195447 154323
271823 133730

output:

11

result:

ok 

Test #3:

score: 0
Accepted
time: 15ms
memory: 81008kb

input:

3
751594 545975
951568 859051
621150 686048

output:

111

result:

ok 

Test #4:

score: 0
Accepted
time: 9ms
memory: 86368kb

input:

3
404592 259430
770816 43371
147329 582162

output:

111

result:

ok 

Test #5:

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

input:

3
401670 296316
401670 809250
401670 595959

output:

110

result:

ok 

Test #6:

score: 0
Accepted
time: 13ms
memory: 82196kb

input:

3
657802 927690
657802 872623
657802 83083

output:

101

result:

ok 

Test #7:

score: 0
Accepted
time: 7ms
memory: 83368kb

input:

3
759291 185618
759291 386687
759291 100713

output:

011

result:

ok 

Test #8:

score: 0
Accepted
time: 15ms
memory: 80444kb

input:

3
997737 106763
684497 106763
412296 106763

output:

101

result:

ok 

Test #9:

score: 0
Accepted
time: 11ms
memory: 80388kb

input:

3
305388 642835
538743 642835
608034 642835

output:

101

result:

ok 

Test #10:

score: 0
Accepted
time: 11ms
memory: 80528kb

input:

3
420692 202248
784725 202248
931773 202248

output:

101

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #11:

score: 11
Accepted
time: 11ms
memory: 86276kb

input:

16
296455 404592
582162 770816
807435 536085
259430 536085
112538 770816
610915 369095
582162 369095
94860 147329
112538 147329
296455 61932
259430 147329
807435 369095
610915 404592
807435 309191
807435 61932
94860 770816

output:

1111011101101011

result:

ok 

Test #12:

score: -11
Wrong Answer
time: 16ms
memory: 83408kb

input:

16
561476 595959
58474 595959
58474 664431
105001 143086
809250 250085
58474 250085
789588 281386
350332 161786
789588 250085
561476 281386
296316 401670
296316 250085
350332 595959
296316 161786
350332 281386
58474 281386

output:

0111110101101111

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 272ms
memory: 88680kb

input:

92690
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 

Subtask #4:

score: 6
Accepted

Test #38:

score: 6
Accepted
time: 224ms
memory: 103928kb

input:

1000000
1 18543
4 40327
7 19084
8 44274
10 42366
12 22173
13 9862
15 44706
19 48070
21 13389
24 39273
26 18680
27 46858
28 46126
32 27753
34 28289
36 12220
38 39235
42 28505
45 47348
46 34220
48 47551
50 49156
54 8856
55 25515
56 21932
58 24482
59 20686
61 41381
66 30112
67 44504
70 24510
71 26418
7...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #39:

score: 0
Accepted
time: 213ms
memory: 101416kb

input:

1000000
2 21155
4 41232
6 20287
7 46837
9 38631
11 6901
15 43358
16 10142
19 28642
20 33035
21 27599
24 20951
27 12983
30 11366
31 20539
32 10621
34 30734
37 6043
41 5841
43 8213
46 8479
47 12328
49 5893
50 22485
51 39760
52 8737
54 43535
56 24827
57 15847
59 8402
61 23013
65 17937
66 18072
69 36863...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111110...

result:

ok 

Test #40:

score: 0
Accepted
time: 218ms
memory: 102532kb

input:

1000000
1 44308
3 27877
4 48227
6 27660
8 26210
9 43909
10 11659
11 34110
13 39632
15 7390
17 40561
20 7928
24 24624
25 9113
27 28937
29 23508
30 41645
32 38110
34 10958
36 37937
37 46339
38 41683
40 7125
41 11569
42 9531
44 29591
45 45867
46 48643
49 7654
50 33740
52 26995
55 13345
57 22001
59 1247...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #41:

score: 0
Accepted
time: 221ms
memory: 102956kb

input:

1000000
2 31149
4 25209
7 47632
9 13365
10 23457
12 38193
14 6534
15 33175
16 12181
19 26329
21 7294
24 25786
26 39155
27 12081
29 31350
33 16989
36 34867
38 31751
39 38661
41 17345
44 24470
47 41098
48 41797
51 27139
53 40756
54 15934
59 28395
63 46853
64 46994
66 14330
67 46212
69 23352
70 8115
72...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #42:

score: 0
Accepted
time: 223ms
memory: 101524kb

input:

1000000
1 38450
2 25296
5 6604
7 5068
8 44733
10 49030
11 48217
12 11533
14 7208
15 37097
16 13793
21 41955
23 45683
25 31223
27 27252
28 26319
30 9053
35 41698
36 18276
41 20100
42 32537
44 41677
46 37754
48 28572
50 44106
52 43957
56 21750
57 21732
61 12737
64 45597
66 42872
67 9711
68 25897
69 41...

output:

111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111...

result:

ok 

Test #43:

score: 0
Accepted
time: 484ms
memory: 158972kb

input:

1000000
2 880200
3 405629
4 505753
8 827569
9 249542
15 230517
19 801043
21 393006
23 167265
25 246534
28 302737
32 665950
33 146821
35 765079
36 349562
37 691530
39 446351
40 692089
42 997833
43 688018
44 185484
46 236680
48 414992
50 677116
52 922426
55 930670
57 429844
58 978728
60 671339
62 2508...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #44:

score: 0
Accepted
time: 474ms
memory: 158828kb

input:

1000000
1 905626
2 338678
5 553579
7 552200
8 784328
10 112106
11 928788
12 719285
14 737963
16 204427
17 313941
19 504387
21 61669
22 430904
24 75978
25 248640
26 317625
29 619690
31 193568
32 966216
34 851031
36 964644
37 111735
38 50038
39 436056
41 165749
42 733480
44 45671
46 501053
47 394829
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #45:

score: 0
Accepted
time: 487ms
memory: 156876kb

input:

1000000
1 524431
7 627962
11 814078
12 347856
14 929279
16 407341
19 77713
22 938040
25 611644
26 421438
27 39608
29 875594
31 950490
33 938280
35 569458
36 399569
37 565433
39 200899
41 512932
42 892335
45 785082
49 138075
52 556802
55 964794
56 23280
59 765396
63 56095
65 334489
67 116493
68 64798...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #46:

score: 0
Accepted
time: 475ms
memory: 158916kb

input:

1000000
2 793441
5 57521
6 977344
8 152182
9 474068
10 56149
12 388264
15 295964
16 404775
18 333353
19 544761
21 208229
22 409823
26 71607
27 49633
30 748788
32 202839
35 362645
37 896518
38 500521
40 561975
41 682139
42 328620
44 733819
45 687203
47 184074
50 496029
52 831999
53 302832
54 228451
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #47:

score: 0
Accepted
time: 483ms
memory: 158832kb

input:

1000000
1 895838
2 325421
3 954723
4 164307
6 340013
7 825549
10 3829
14 523251
15 52480
17 752743
19 256730
21 743287
24 342268
25 348119
27 164916
28 961505
31 446402
33 903443
37 867901
39 765398
40 319469
41 495869
43 425064
45 442601
48 826731
51 870551
53 419326
54 456719
57 200828
59 642520
6...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Wrong Answer

Test #85:

score: 0
Wrong Answer
time: 512ms
memory: 156752kb

input:

1000000
1 602300
1 778881
2 397065
3 291452
3 678039
5 235300
6 499367
8 8597
10 327718
10 516489
12 416542
12 440048
13 284169
13 383581
13 642202
13 770858
14 378154
14 710033
15 905531
16 50155
17 142259
19 395613
19 500321
20 358934
21 461772
24 562953
24 995887
25 421244
27 900412
29 301006
31 ...

output:

111111111111111111111111111111111111111111111101111111111111111111111111111111111101111111111111111111111011111111111111111111111111111011111111111011100111101111111111010111111111111111000111111111111111111111111111111111111111111111111111111111111111110111111111011111111111111111111111111110011111...

result:

wrong answer