QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560549#3590. Joining PairsYarema#AC ✓38ms5264kbC++201.1kb2024-09-12 16:22:292024-09-12 16:22:29

Judging History

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

  • [2024-09-12 16:22:29]
  • 评测
  • 测评结果:AC
  • 用时:38ms
  • 内存:5264kb
  • [2024-09-12 16:22:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int w, h, n;
	cin >> w >> h >> n;
	auto f = [&](int x, int y)
	{
		if (y == 0)
			return x;
		if (x == w)
			return w + y;
		if (y == h)
			return w + h + (w - x);
		if (x == 0)
			return w + h + w + (h - y);
		return -1;
	};
	vector<PII> vec;
	FOR(i, 0, n)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int f1 = f(x1, y1), f2 = f(x2, y2);
		if (f1 != -1 && f2 != -1)
		{
			vec.PB({f1, i});
			vec.PB({f2, i});
		}
	}
	sort(ALL(vec));
	stack<int> s;
	for (auto [_, i] : vec)
	{
		if (!s.empty() && s.top() == i)
			s.pop();
		else
			s.push(i);
	}
	cout << (s.empty() ? "Y\n" : "N\n");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Y

result:

ok single line: 'Y'

Test #2:

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

input:

98 96
20
12 96 79 0
38 0 41 0
0 19 0 53
98 55 98 43
98 62 98 33
44 96 66 96
0 86 6 96
91 96 98 94
98 9 98 7
98 68 86 0
33 96 37 96
17 0 50 0
29 0 19 0
83 0 68 96
0 73 49 0
98 32 98 20
0 85 88 96
57 96 59 96
84 0 4 0
36 0 32 0

output:

N

result:

ok single line: 'N'

Test #3:

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

input:

92 94
20
0 71 20 94
28 94 30 94
0 8 92 82
0 49 0 50
0 78 0 94
84 0 92 27
89 0 92 36
57 94 92 85
0 39 23 94
38 94 41 94
88 94 80 0
92 81 92 3
92 6 51 0
92 57 92 8
32 94 43 94
0 47 0 51
0 31 67 94
55 94 92 59
92 53 92 14
18 0 17 0

output:

N

result:

ok single line: 'N'

Test #4:

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

input:

98 98
20
0 41 47 0
0 20 18 0
17 98 91 0
0 6 12 0
0 4 6 0
34 98 98 7
87 98 98 78
88 98 98 90
83 98 98 55
0 83 82 0
0 59 64 0
0 36 36 0
78 98 98 28
0 66 65 0
0 57 56 0
0 51 55 0
79 98 98 31
91 98 93 98
0 69 73 0
0 25 35 0

output:

Y

result:

ok single line: 'Y'

Test #5:

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

input:

92 92
20
42 92 46 92
70 0 64 0
54 0 39 0
92 16 92 5
26 0 7 0
0 6 0 8
58 92 61 92
92 60 92 55
0 38 0 39
0 59 0 74
0 84 39 92
0 53 0 57
87 0 86 0
65 92 66 92
92 48 92 27
92 79 92 78
67 92 73 92
92 4 91 0
82 92 92 83
0 9 0 26

output:

Y

result:

ok single line: 'Y'

Test #6:

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

input:

98 91
20
37 91 98 25
21 91 62 0
98 61 98 55
67 91 98 43
27 91 84 0
25 91 79 0
0 50 13 0
15 91 61 0
0 46 2 0
98 60 98 57
46 91 98 41
6 91 52 0
98 64 98 48
85 0 98 46
36 91 94 0
0 83 32 0
0 69 24 0
0 57 16 0
34 91 77 91
0 85 43 0

output:

N

result:

ok single line: 'N'

Test #7:

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

input:

90 95
20
90 78 24 95
0 37 0 45
68 95 74 95
36 95 40 95
12 0 8 0
36 0 33 0
0 94 2 95
90 70 90 58
90 89 16 95
90 10 90 7
41 95 52 95
76 95 85 95
86 95 88 95
90 39 90 19
31 0 30 0
77 0 73 0
0 10 0 20
0 4 0 6
0 29 0 35
69 0 57 0

output:

N

result:

ok single line: 'N'

Test #8:

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

input:

976912198 972725809
10000
976912198 888021982 976912198 887909771
976912198 211477996 976912198 211244427
976912198 159160117 976912198 159115222
148408340 0 147818618 0
799694348 0 799553992 0
866871522 972725809 867150661 972725809
976912198 966001317 976912198 964455243
976912198 307453876 976912...

output:

Y

result:

ok single line: 'Y'

Test #9:

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

input:

924944126 949800785
10001
117228794 0 117226291 0
881162392 0 881070769 0
0 349826101 0 350678243
924944126 24725929 924944126 24640518
0 331551886 0 334994497
765605363 0 765462009 0
0 64638974 0 65093870
449520118 949800785 449577276 949800785
924944126 187276056 924944126 187034246
924944126 4887...

output:

Y

result:

ok single line: 'Y'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

911527345 984619968
10012
117245245 0 114607968 0
752562168 0 752263088 0
911527345 173882672 911527345 173814028
777351405 0 775794021 0
732395950 0 732364473 0
0 821908966 0 822001500
99302343 0 98955314 0
0 122853626 0 122862433
911527345 982809420 911527345 982598086
669632787 0 669502153 0
6406...

output:

Y

result:

ok single line: 'Y'

Test #11:

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

input:

966023928 922318982
10123
966023928 4575395 966023928 3780095
528297195 922318982 528858278 922318982
966023928 70683172 966023928 65645565
171356773 0 170120831 0
0 335946730 0 335964700
966023928 66414680 966023928 66361276
413607692 0 413199694 0
742188262 0 741992713 0
939656476 0 939590889 0
50...

output:

Y

result:

ok single line: 'Y'

Test #12:

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

input:

5 5
2
4 0 3 5
5 3 0 2

output:

N

result:

ok single line: 'N'

Test #13:

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

input:

926116333 923042331
11234
0 529270342 0 529772346
899213642 0 899209861 0
294187708 0 293464472 0
737202594 344382372 376021126 855173483
604197671 0 603818698 0
926116333 329479917 926116333 329305579
926116333 105399807 926116333 105003599
864792 923042331 864952 923042331
708085082 923042331 7181...

output:

Y

result:

ok single line: 'Y'

Test #14:

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

input:

930624995 972361940
10000
930624995 204282730 930624995 194609170
84365064 972361940 84667349 972361940
930624995 884982670 930624995 884817364
930624995 521194377 930624995 520961487
0 163768158 0 164618841
577913890 0 576994875 0
251334554 972361940 251615910 972361940
791597923 972361940 79196528...

output:

N

result:

ok single line: 'N'

Test #15:

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

input:

945340690 954678737
10001
945340690 285789830 945340690 285543887
516744715 954678737 517499581 954678737
737962520 954678737 739199697 954678737
489343761 954678737 489571944 954678737
772233630 0 771988541 0
62591925 954678737 62735827 954678737
0 194609108 0 195202159
945340690 542538385 94534069...

output:

N

result:

ok single line: 'N'

Test #16:

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

input:

926741146 907624071
10012
0 539866524 0 551907177
431572767 907624071 431956777 907624071
95940536 907624071 96471049 907624071
567813267 0 926741146 300943043
926741146 355949595 618063970 907624071
0 825300004 0 825494991
141276210 0 140766526 0
828148145 0 826834227 0
132036326 907624071 13337163...

output:

N

result:

ok single line: 'N'

Test #17:

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

input:

987770732 917830625
10123
567541155 917830625 567927897 917830625
0 150765098 0 151373145
322789068 917830625 325243317 917830625
0 560424894 0 563009755
0 576576865 258454007 0
987770732 772002141 987770732 771869348
614958360 0 612820948 0
686682248 0 686184953 0
0 458345843 0 459338083
283009505 ...

output:

N

result:

ok single line: 'N'

Test #18:

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

input:

945106672 971807903
11234
741877526 971807903 742071908 971807903
143022903 0 142357856 0
229702409 971807903 230668902 971807903
945106672 575885316 945106672 575874950
945106672 608766605 945106672 608377042
311905229 659439511 775481896 776041218
739128797 971807903 739457730 971807903
0 34816821...

output:

N

result:

ok single line: 'N'

Test #19:

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

input:

984215017 950003196
10000
133525237 900478400 538352812 465801605
96661676 117465505 750067522 27188073
830454180 561653303 103307584 31509704
770054263 503784667 837908294 108186870
29767751 620840858 338804773 19975652
9561227 187292302 460702239 772428105
906881485 707372501 527688722 146586627
8...

output:

Y

result:

ok single line: 'Y'

Test #20:

score: 0
Accepted
time: 3ms
memory: 3748kb

input:

927114756 947543741
10000
15292600 383941100 842895229 712093781
334039577 351543078 746520494 649497079
909014008 418383476 51756797 767182678
488950540 690256977 874193834 674900556
381878920 285583010 127399495 242503643
608689481 673780653 641167064 814232664
747723135 65105540 650533089 6975563...

output:

Y

result:

ok single line: 'Y'

Test #21:

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

input:

948498426 907087070
10000
906687190 794663256 41392249 556814958
435989454 18379404 650918381 567053489
660125851 724735530 429014819 897341960
233052345 8960067 630231092 249333934
877534223 804642228 388018813 68994546
161152190 189388739 937380740 456947097
520276329 729597147 4815706 574987343
7...

output:

Y

result:

ok single line: 'Y'

Test #22:

score: 0
Accepted
time: 30ms
memory: 5168kb

input:

1000000000 1000000000
100000
120002699 0 119981553 0
428341176 0 428309699 0
876035281 1000000000 876038354 1000000000
1000000000 937811861 1000000000 937808542
578080801 1000000000 578122107 1000000000
164627619 1000000000 164635475 1000000000
825608760 0 825601174 0
666895781 1000000000 666905667 ...

output:

Y

result:

ok single line: 'Y'

Test #23:

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

input:

94 90
20
50 45 69 20
65 84 81 17
40 39 34 87
31 0 30 0
39 41 46 19
6 59 35 26
40 2 32 80
18 74 86 83
33 90 91 0
85 90 94 23
50 0 4 0
0 2 57 0
0 31 3 90
91 27 64 59
0 14 25 90
23 90 24 90
73 85 0 5
26 25 73 44
89 0 72 0
94 90 94 82

output:

Y

result:

ok single line: 'Y'

Test #24:

score: 0
Accepted
time: 37ms
memory: 5264kb

input:

1000000000 1000000000
100000
1000000000 617302880 1000000000 616949416
225884407 1000000000 226021072 1000000000
97564963 1000000000 97597033 1000000000
437669798 1000000000 437681807 1000000000
0 763234104 0 763240493
1000000000 783824469 1000000000 783815327
1000000000 276033467 1000000000 2760198...

output:

Y

result:

ok single line: 'Y'

Test #25:

score: 0
Accepted
time: 37ms
memory: 5244kb

input:

1000000000 1000000000
100000
427336078 1000000000 1000000000 430220349
190937677 1000000000 1000000000 196837716
0 370787666 379687324 0
0 404296241 413339797 0
367903080 1000000000 1000000000 374970689
0 758134857 769495055 0
0 792736370 803927599 0
0 617145070 629764398 0
0 752900827 763590778 0
0...

output:

Y

result:

ok single line: 'Y'

Test #26:

score: 0
Accepted
time: 38ms
memory: 5168kb

input:

1000000000 1000000000
100000
1000000000 529420537 1000000000 529394781
1000000000 985012064 1000000000 984999767
984638165 0 984589119 0
1000000000 674038799 1000000000 674015048
1000000000 259854781 1000000000 259835861
1000000000 736354530 1000000000 736342596
1000000000 409796900 1000000000 40978...

output:

Y

result:

ok single line: 'Y'

Test #27:

score: 0
Accepted
time: 30ms
memory: 4300kb

input:

1000000000 1000000000
100000
387715500 1000000000 387826340 1000000000
0 752071520 0 752151391
555613693 595047435 652397054 25955935
0 589932966 0 589996392
79096044 822285148 396457502 290796691
817402984 419274812 872774353 110534417
0 175297493 0 177257443
1000000000 302539453 1000000000 3025374...

output:

Y

result:

ok single line: 'Y'

Test #28:

score: 0
Accepted
time: 30ms
memory: 4304kb

input:

1000000000 1000000000
100000
161387974 0 161384284 0
1000000000 300391017 1000000000 299726930
762882320 431858659 477796507 346344974
738704869 29047075 178624582 24188233
121016949 17661876 416643851 426362050
1000000000 468509661 1000000000 468184435
103109235 0 103088858 0
0 402924412 0 40294037...

output:

N

result:

ok single line: 'N'

Test #29:

score: 0
Accepted
time: 30ms
memory: 4300kb

input:

1000000000 1000000000
100000
42166470 63269329 630727059 596891616
850806835 122628381 789122675 21685504
104219294 152638082 488510709 523556977
848954190 0 848921380 0
571178920 793435804 470270568 793182777
1000000000 854868382 1000000000 854864410
555255086 739942842 947646239 284372810
23991840...

output:

N

result:

ok single line: 'N'

Test #30:

score: 0
Accepted
time: 31ms
memory: 4128kb

input:

1000000000 1000000000
100000
180969008 1000000000 181010615 1000000000
224742815 555796219 542992191 805392057
0 381492711 225308126 1000000000
0 407847644 0 407967551
624874631 960695539 627665096 333775524
775816904 420444135 301456520 953722204
1000000000 376020642 1000000000 386003027
244724993 ...

output:

N

result:

ok single line: 'N'

Test #31:

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

input:

95 93
20
0 36 6 93
0 30 90 93
0 65 0 88
95 17 95 16
13 0 3 0
49 0 37 0
95 87 95 75
95 70 95 69
30 93 49 93
95 10 77 0
0 57 0 93
16 93 64 93
60 0 52 0
14 93 72 93
0 12 29 0
93 93 95 32
86 0 83 0
95 14 31 0
76 93 81 93
95 89 95 47

output:

Y

result:

ok single line: 'Y'

Test #32:

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

input:

97 100
20
0 0 49 0
36 0 34 0
77 100 85 100
0 69 45 100
0 80 3 100
90 100 97 81
0 11 88 100
97 96 97 90
0 22 61 100
0 32 0 65
0 35 0 57
97 65 97 59
75 0 71 0
26 0 4 0
91 100 97 83
55 0 53 0
97 40 97 17
97 79 86 0
0 19 63 100
97 77 97 47

output:

Y

result:

ok single line: 'Y'

Test #33:

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

input:

97 93
20
57 93 97 43
45 0 44 0
0 75 18 93
0 53 0 59
90 0 68 0
0 92 0 93
97 52 97 49
0 65 0 66
22 93 97 13
0 17 0 62
66 93 97 56
0 12 20 93
0 7 60 0
0 15 0 70
42 93 97 19
28 93 40 93
52 0 29 0
11 93 14 93
8 93 17 93
19 0 14 0

output:

Y

result:

ok single line: 'Y'

Test #34:

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

input:

99 90
20
62 90 2 78
84 42 27 2
3 37 70 42
54 31 80 42
27 1 35 62
46 6 58 4
97 5 68 76
76 90 53 21
97 16 18 50
59 10 74 88
23 21 73 25
24 87 18 6
99 16 10 83
65 18 54 75
60 21 17 63
32 46 59 90
69 15 29 8
60 19 58 39
32 43 65 69
59 43 40 78

output:

Y

result:

ok single line: 'Y'

Test #35:

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

input:

90 99
20
0 42 0 91
37 77 88 21
0 40 0 93
85 0 72 0
80 68 45 83
62 88 28 97
90 49 90 8
0 8 90 42
55 99 90 55
37 8 27 18
25 84 57 31
0 15 6 99
58 99 60 99
33 49 20 62
30 49 63 57
67 0 64 0
10 57 69 67
0 28 0 37
44 11 44 87
40 42 41 20

output:

N

result:

ok single line: 'N'

Test #36:

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

input:

94 99
20
0 62 94 33
7 99 25 99
64 99 94 45
0 32 0 33
85 0 71 0
94 22 94 17
62 99 94 41
94 92 94 86
12 99 0 49
0 12 50 99
67 99 73 99
81 99 94 60
13 99 0 9
53 0 11 0
94 29 94 9
9 0 8 0
34 0 26 0
32 99 43 99
0 83 27 99
41 0 21 0

output:

N

result:

ok single line: 'N'