QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#199184#7517. Flying Ship Storyucup-team1325AC ✓311ms3852kbC++172.1kb2023-10-03 22:33:542023-10-03 22:33:54

Judging History

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

  • [2023-10-03 22:33:54]
  • 评测
  • 测评结果:AC
  • 用时:311ms
  • 内存:3852kb
  • [2023-10-03 22:33:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll; typedef unsigned long long ull;
const int inf = 1e9; const ll llnf = 4e18;

template< class Tp > void chkmax( Tp &x , Tp y ) { x = max( x , y ); }
template< class Tp > void chkmin( Tp &x , Tp y ) { x = min( x , y ); }

// 若干个十字的交
// 一定是 <= 1 个横线, <= 1 个竖线, <= 2 个单点 的并

struct Info {
private:
	int x , y; vector< pair< int , int > > z;

public:
	Info( int x0 , int y0 ) { x = x0 , y = y0 , z.clear( ); }
	Info comp( int x0 , int y0 ) const {
		Info ans = Info( x , y );
		if( x != -1 && x != x0 ) ans.x = -1 , ans.z.emplace_back( x , y0 );
		if( y != -1 && y != y0 ) ans.y = -1 , ans.z.emplace_back( x0 , y );
		for( auto [ u , v ] : z ) if( u == x0 || v == y0 ) ans.z.emplace_back( u , v );
		sort( ans.z.begin( ) , ans.z.end( ) ) , ans.z.erase( unique( ans.z.begin( ) , ans.z.end( ) ) , ans.z.end( ) );
		return ans;
	}
	bool sam( const Info &that ) const { return x == that.x && y == that.y && z == that.z; }
} ;

void solve( ) {
	int q; cin >> q;

	vector< tuple< int , int , int > > useful; int lstans = 0;
	while( q -- ) {
		int opt; cin >> opt;
		if( opt == 1 ) {
			int x , y , w; cin >> x >> y >> w; x ^= lstans , y ^= lstans , w ^= lstans;
			useful.emplace_back( w , x , y ); sort( useful.begin( ) , useful.end( ) , greater< tuple< int , int , int > >( ) );
			vector< tuple< int , int , int > > nuseful{ useful[0] }; Info info( get< 1 >( useful[0] ) , get< 2 >( useful[0] ) );
			for( int i = 1; i < ( int ) useful.size( ); i ++ ) {
				Info ninfo = info.comp( get< 1 >( useful[i] ) , get< 2 >( useful[i] ) );
				if( !info.sam( ninfo ) ) nuseful.emplace_back( useful[i] ) , info = ninfo;
			}
			useful = nuseful;
		}
		if( opt == 2 ) {
			int x , y; cin >> x >> y; x ^= lstans , y ^= lstans;
			int ans = 0; for( auto [ w , u , v ] : useful ) if( u != x && v != y ) chkmax( ans , w );
			cout << ans << "\n"; lstans = ans;
		}
	}
}

int main( ) {
	ios::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 );
	int T = 1; while( T -- ) solve( ); return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
1
0

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 257ms
memory: 3852kb

input:

1000000
2 370943499 431961772
1 1 1 11995570
2 37566858 838793045
1 11995571 11995569 908148975
2 11995571 11995571
1 1 3 716821068
2 67877937 3
1 11995571 11995571 771898489
2 38381714 99749723
1 915818844 915818847 729541681
2 592361351 915818846
1 783627722 783627722 639375021
2 102203700 8636489...

output:

0
11995570
0
11995570
915818845
783627723
915818845
0
0
915818845
0
783627723
0
904468304
904468304
904468304
915818845
904468304
915818845
904468304
915818845
0
904468304
0
915818845
915818845
0
0
915818845
915818845
0
921710773
0
921710773
998138906
921710773
0
921710773
998138906
0
998138906
0
99...

result:

ok 500000 lines

Test #3:

score: 0
Accepted
time: 287ms
memory: 3556kb

input:

1000000
2 648544745 437316088
1 1 1 221075686
2 802693951 691188141
1 221075687 221075684 1036811136
2 771835961 178451319
1 820061031 820061031 560017372
2 829408420 820061028
1 293604539 293604539 699366423
2 293604539 293604539
1 1 2 610044241
2 50747012 885321059
1 942633132 942633132 603537610
...

output:

0
221075686
820061030
293604538
0
942633133
942633133
27478144
820061030
820061030
900696946
27478144
942633133
942633133
0
772167494
27478144
891145650
900696946
772167494
891145650
918281274
772167494
772167494
772167494
772167494
772167494
942633133
918281274
891145650
918281274
891145650
8911456...

result:

ok 500000 lines

Test #4:

score: 0
Accepted
time: 296ms
memory: 3804kb

input:

1000000
2 488777832 43440411
1 441939805 62137297 1349
2 198318033 382339804
1 441938456 72190649 815
2 458351680 72190649
1 441938456 287971850 290
2 161496970 653240491
1 933968337 49827233 1142
2 441938231 49827233
1 623590902 306969890 440
2 441939805 144230480
1 441939265 480404387 11460
2 4419...

output:

0
1349
1349
1642
0
540
440
440
440
11992
4593
4228
9603
4228
12488
7139
4593
14051
14051
14051
16301
4593
20640
14051
34628
20640
34628
35421
34628
34628
49987
11225
17743
11225
17743
35421
17743
35421
17743
49987
56227
56227
11225
11225
56227
56227
56227
56227
56227
37643
37643
49987
37643
37643
21...

result:

ok 500000 lines

Test #5:

score: 0
Accepted
time: 296ms
memory: 3616kb

input:

1000000
2 300988902 687022441
1 363810072 24403398 289
2 441308798 688376935
1 628472989 502933923 685
2 628472989 24403175
1 405185660 444382475 5415
2 405185660 502933634
1 628472989 220347248 2326
2 405185885 151256307
1 38349408 55729241 318
2 996330001 736739645
1 628467867 508628958 4399
2 567...

output:

0
289
0
289
2103
5415
5415
2103
8914
10615
3349
3349
8956
3349
10129
10129
6943
15708
10615
15708
10615
15708
10615
16924
13341
13341
16924
16924
16924
40745
16924
21956
40745
12104
40745
20471
40745
40745
20471
40745
40745
63618
40745
63618
63618
18063
63618
63618
63618
79351
79351
79351
79351
6361...

result:

ok 500000 lines

Test #6:

score: 0
Accepted
time: 292ms
memory: 3560kb

input:

1000000
2 111806459 80284370
1 796602332 100051686 438
2 286632803 842428594
1 34142446 621400092 731
2 53723669 621400092
1 449442772 930459341 4955
2 443764325 137040488
1 748083857 223767926 8188
2 969939167 515353275
1 989422739 346378721 4227
2 748083857 930463126
1 103490800 749046598 2463
2 3...

output:

0
438
438
4845
4845
877
4845
3345
3345
3345
3345
6408
6416
7738
3656
3656
11278
3656
13839
11278
33567
33567
5723
33567
28274
28274
8997
11278
48613
33567
8997
11278
8997
8997
13336
26477
48613
13336
48613
13336
13336
48613
26477
26766
13336
73778
73778
58976
42110
42110
22285
73778
73778
73778
7377...

result:

ok 500000 lines

Test #7:

score: 0
Accepted
time: 293ms
memory: 3560kb

input:

1000000
2 718033726 616016120
1 665760898 359791620 366
2 665760898 204722547
1 452321281 333162973 3799
2 60737187 883719093
1 452325078 2420293 2737
2 464822496 333162250
1 897358098 996437487 472
2 795171894 333163963
1 455003715 996437047 3228
2 787981736 996272822
1 882324943 996435806 3458
2 4...

output:

0
0
3799
1126
1470
3799
1470
1470
705
7238
3252
2338
3252
10340
10340
8986
5114
5114
5114
13813
17199
10340
18118
18118
21931
21931
5114
21931
21931
21931
29195
29195
15488
35715
31726
57783
15488
33759
33759
57783
15488
15488
68258
68258
15488
68258
33759
87915
33759
15488
15488
33759
33759
68258
1...

result:

ok 500000 lines

Test #8:

score: 0
Accepted
time: 291ms
memory: 3620kb

input:

1000000
2 78038813 250486402
1 695391094 534886695 519
2 304811423 718140553
1 158043817 277922962 304
2 803420509 772623626
1 856526470 455200407 6075
2 856526470 211646382
1 589013496 642317455 2046
2 856526470 781887716
1 3773409 455199081 7129
2 489372518 198447772
1 695389286 769439586 7294
2 4...

output:

0
519
823
823
1225
7952
1225
7952
5260
3036
7952
7952
5260
7952
7952
15312
15312
7952
15312
15312
16011
16011
16011
10390
15174
15312
16011
16011
16011
21629
37469
44676
21629
11376
21629
44676
44676
11376
21629
63531
14384
21629
14384
62379
62379
17290
62379
62379
63531
17290
62379
63531
63531
6353...

result:

ok 500000 lines

Test #9:

score: 0
Accepted
time: 290ms
memory: 3664kb

input:

1000000
2 448731011 335554536
1 457642829 423410972 124853177
2 528804845 610815786
1 670970781 30756690 76799653
2 473303284 30756690
1 738493740 200328550 305876016
2 831084154 333999700
1 216806 432769366 522523742
2 886066341 327404401
1 159145853 823055029 119343195
2 1044367644 823055029
1 374...

output:

0
124853177
0
305876016
305876016
220092526
354829419
65193244
385224642
494032668
494032668
494032668
89190365
884278417
804675940
129416032
804675940
494032668
494032668
884278417
804675940
884278417
494032668
884278417
884278417
884278417
494032668
192215999
494032668
494032668
494032668
49403266...

result:

ok 500000 lines

Test #10:

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

input:

1000000
2 153972288 431605536
1 730858411 118081523 61101718
2 597918421 118081523
1 302485264 707599297 51792879
2 666912261 118081523
1 553921748 222588592 19087596
2 679888964 691753006
1 539454520 901424574 281552883
2 780874631 872495545
1 820988875 320547849 114233419
2 245557822 320547849
1 7...

output:

0
0
51792879
37030659
318582000
318582000
338836667
224502837
61101718
481847491
481847491
481847491
814391513
208713218
814391513
695505776
246189170
814391513
695505776
695505776
814391513
814391513
246189170
481847491
481847491
481847491
481847491
695505776
481847491
814391513
481847491
814391513...

result:

ok 500000 lines

Test #11:

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

input:

1000000
2 1756180 842292352
1 749493858 260143625 424
2 985509420 740477290
1 636015984 920180987 292
2 699490704 38801725
1 466966973 773251960 814
2 373096904 461012336
1 199555803 702448186 586
2 466967187 942269722
1 43386889 661927555 758
2 368307964 767725271
1 466967371 652656431 1610
2 46696...

output:

0
424
424
646
424
862
424
3755
1300
3755
12705
1926
1926
3755
2616
3755
3755
24100
3755
2616
5891
2616
5891
4151
5891
5891
41248
10033
5891
41248
41248
41248
16593
15320
5680
16593
8111
8111
41248
8111
15320
41248
8111
31591
9024
15320
15320
15320
9024
74059
74059
24087
24087
31591
31591
74059
74059...

result:

ok 500000 lines

Test #12:

score: 0
Accepted
time: 287ms
memory: 3592kb

input:

1000000
2 418305042 944656569
1 360849688 469845427 1126
2 347770605 7106815
1 264338323 253721049 1533
2 940700400 34983084
1 360850814 469844437 2067
2 360850814 443687475
1 111887484 469845032 238
2 303710556 850291600
1 579127458 578143118 3253
2 560575977 302928526
1 264336256 211480818 1794
2 ...

output:

0
1126
1126
411
3189
3189
3189
2935
7725
7725
192
1775
3421
3189
3189
3189
1775
6608
6608
7725
7725
37311
6608
37311
6608
5714
5714
6608
5714
7725
6608
37311
14524
15851
15851
37311
21334
5714
5714
5714
37311
7210
7210
21334
21334
7210
21334
21334
19271
37311
19271
7210
7210
19271
19271
19271
13320
...

result:

ok 500000 lines

Test #13:

score: 0
Accepted
time: 277ms
memory: 3620kb

input:

1000000
2 804115895 2661276
1 180734654 156813060 300
2 253741442 156813060
1 472942411 314635336 231
2 87507808 156813060
1 349452733 767165 1911
2 349452733 156813283
1 472942508 217877748 416
2 349452733 96729439
1 472942092 59977469 119
2 472942092 767261
1 945007344 767350 1508
2 274364371 3192...

output:

0
0
231
231
327
300
1936
2204
2204
1936
3744
3744
3744
2867
2867
1759
6346
6346
6346
6346
1759
6346
6346
4476
6346
4476
4476
16555
4476
4476
6022
10043
10043
10043
16555
6022
6022
16555
16555
6022
67548
6022
12030
12030
67548
12030
18086
33442
6022
33442
33442
6022
20211
33442
67548
33442
67548
6754...

result:

ok 500000 lines

Test #14:

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

input:

1000000
2 103013178 687790552
1 247109364 453485616 417
2 247109364 560197
1 301015532 533028723 397
2 61889261 157540231
1 247109461 730927600 167
2 247109461 292968626
1 781831237 475527032 758
2 715010644 138797384
1 301015703 42413404 459
2 67760275 589415471
1 665349790 944974343 285
2 78183185...

output:

0
0
417
397
891
891
688
3230
688
3230
1253
9794
1253
3230
3230
9794
3230
9794
5992
3230
3230
3230
5992
5992
5992
13944
23480
23480
4013
13944
23480
23480
4013
26211
42117
42117
12844
12844
60131
26211
7996
26211
26211
26211
9971
26211
26211
60131
60131
13482
13482
12149
12149
13482
13482
13482
12149...

result:

ok 500000 lines

Test #15:

score: 0
Accepted
time: 311ms
memory: 3628kb

input:

1000000
2 571465209 203365081
1 466753949 726269346 120489823
2 466753949 369486616
1 466753949 601231229 251422109
2 466753949 726269346
1 131434952 337438435 82190750
2 466753949 726269346
1 520104744 284870525 55655366
2 421460934 74147403
1 310575874 450921342 743860879
2 355367936 450921342
1 1...

output:

0
0
0
82190750
251422109
0
581570322
581570322
581570322
150072005
150072005
124030323
581570322
581570322
124030323
251422109
251422109
124030323
169831141
251422109
124030323
882989709
882989709
169831141
169831141
169831141
882989709
169831141
124392464
169831141
124392464
169831141
882989709
882...

result:

ok 500000 lines