QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412976#8315. Candy AdsieeML 422ms428264kbC++172.6kb2024-05-16 22:49:322024-05-16 22:49:33

Judging History

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

  • [2024-05-16 22:49:33]
  • 评测
  • 测评结果:ML
  • 用时:422ms
  • 内存:428264kb
  • [2024-05-16 22:49:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 50005;
int n, w, h, m;
int l[50005][3], r[50005][3];
bitset<N> e[N], all;
vector<int> es[N];
void prepare() {
	for (int i = 1; i <= n; i++) {
		all.set(i);
	}
	static bitset<N> sl[3][2005], sr[3][2005];
	for (int t = 0; t < 3; t++) {
		for (int i = 1; i <= n; i++) {
			sl[t][r[i][t]].set(i);
			sr[t][l[i][t]].set(i);
		}
		for (int i = 1; i <= 2000; i++) {
			sl[t][i] |= sl[t][i - 1];
		}
		for (int i = 2000; i >= 1; i--) {
			sr[t][i] |= sr[t][i + 1];
		}
	}
	for (int i = 1; i <= n; i++) {
		e[i] = all;
		for (int t = 0; t < 3; t++) {
			e[i] &= (all ^ (sl[t][l[i][t] - 1] | sr[t][r[i][t] + 1]));
		}
		e[i].reset(i);
	}
	cin >> m;
	for (int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		es[u].push_back(v);
		es[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		sort(es[i].begin(), es[i].end());
		es[i].erase(unique(es[i].begin(), es[i].end()), es[i].end());
	}
}
bitset<N> nov0, nov1;
vector<int> ord;
void dfs1(int u) {
	if (u <= n && !nov0[u]) return;
	if (u > n && !nov1[u - n]) return;
	if (u <= n) nov0[u] = 0;
	else nov1[u - n] = 0;
	if (u <= n) {
		for (int v : es[u]) {
			dfs1(v + n);
		}
	} else {
		for (int v = (e[u - n] & nov0)._Find_first(); v <= n; v = (e[u - n] & nov0)._Find_next(v)) {
			dfs1(v);
		}
	}
	ord.push_back(u);
}
int bel[N * 2];
int rt;
void dfs2(int u) {
	if (u <= n && !nov0[u]) return;
	if (u > n && !nov1[u - n]) return;
	if (u <= n) nov0[u] = 0;
	else nov1[u - n] = 0;
	bel[u] = rt;
	if (u <= n) {
		for (int v = (e[u] & nov1)._Find_first(); v <= n; v = (e[u] & nov1)._Find_next(v)) {
			dfs2(v + n);
		}
	} else {
		for (int v : es[u - n]) {
			dfs2(v);
		}
	}
}
void kosaraju() {
	for (int i = 1; i <= n; i++) {
		nov0[i] = nov1[i] = 1;
	}
	for (int i = 1; i <= n * 2; i++) {
		dfs1(i);
	}
	reverse(ord.begin(), ord.end());
	for (int i = 1; i <= n; i++) {
		nov0[i] = nov1[i] = 1;
	}
	for (int i : ord) {
		if (i <= n && !nov0[i]) continue;
		if (i > n && !nov1[i - n]) continue;
		++rt;
		dfs2(i);
	}
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> w >> h;
	for (int i = 1; i <= n; i++) {
		cin >> l[i][0] >> r[i][0];
		cin >> l[i][1] >> l[i][2];
		r[i][1] = min(2000, l[i][1] + w - 1);
		r[i][2] = min(2000, l[i][2] + h - 1);
	}
	prepare();
	kosaraju();
	for (int i = 1; i <= n; i++) {
		if (bel[i] == bel[i + n]) {
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	for (int i = 1; i <= n; i++) {
		cout << (bel[i] < bel[i + n]);
	}
	cout << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 81676kb

input:

2 2 2
1 2 1 1
2 3 2 2
1
1 2

output:

Yes
01

result:

ok accepted

Test #2:

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

input:

3 2 2
1 2 1 1
1 3 1 2
2 3 2 2
3
1 2
2 3
1 3

output:

No

result:

ok accepted

Test #3:

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

input:

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

output:

Yes
0010110111

result:

ok accepted

Test #4:

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

input:

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

output:

Yes
0001110100

result:

ok accepted

Test #5:

score: 0
Accepted
time: 8ms
memory: 81816kb

input:

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

output:

Yes
0010110011

result:

ok accepted

Test #6:

score: 0
Accepted
time: 6ms
memory: 81924kb

input:

100 94 194
1461 1945 694 1593
217 353 761 1920
695 982 452 599
1301 1757 662 1862
1355 1574 917 258
1253 1718 10 893
822 1112 623 748
597 925 1196 65
1277 1785 17 1368
1564 1914 1637 545
1363 1810 922 1988
1001 1251 28 156
1678 1978 185 980
1730 1823 145 1803
655 1040 981 1261
593 637 212 555
1358 1...

output:

Yes
1011100101111101010111111110110001011110111111111111011010100111101111111011111111101100111111111001

result:

ok accepted

Test #7:

score: 0
Accepted
time: 12ms
memory: 81888kb

input:

100 108 62
410 579 1353 353
82 560 288 988
32 392 1431 1904
1364 1785 1489 1395
1118 1448 301 1275
995 1149 127 1756
1607 1906 1 1907
1217 1782 291 764
616 840 1552 1006
787 1202 34 200
283 316 3 460
903 1356 822 1469
1110 1370 1144 1880
439 746 509 1376
47 344 73 1807
551 1032 280 851
612 631 262 1...

output:

Yes
0000000100001110010001110100101101011101011001101111100111101110110011111111110111101111111111011111

result:

ok accepted

Test #8:

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

input:

100 61 130
1234 1525 1544 1497
1696 1819 895 1801
1079 1222 1201 1725
1581 1827 420 1191
270 782 261 417
1620 1685 415 79
103 387 832 562
1461 1488 388 1124
1246 1726 1900 874
139 632 984 1770
708 882 1235 1378
98 432 867 560
316 863 1773 1122
782 1080 428 1748
1599 1695 590 1969
1384 1941 449 1137
...

output:

Yes
0010001000101110011110011111011101110101111101111111111110101011110101111111011111111111011111111011

result:

ok accepted

Test #9:

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

input:

1000 46 46
650 693 297 1278
322 411 1293 527
1613 1798 1513 1514
380 440 1463 1779
220 263 1459 1937
718 777 649 81
497 672 1224 818
576 597 977 1728
199 283 827 1766
248 259 1666 1199
956 1092 142 1966
1010 1159 414 186
592 728 1781 673
403 596 1021 1607
1118 1234 1511 417
810 830 1667 1125
1304 14...

output:

Yes
00011000000000000010100001111001100010101100111101110000101100110001010010010110010001000111001101111100111111010111101111000010011101011111100011111001010100110010111001101111110100111101111110110111100010101101111111111111111111101100111110001011101110110011111111100111000111110000110111111111...

result:

ok accepted

Test #10:

score: 0
Accepted
time: 6ms
memory: 87944kb

input:

1000 36 48
1100 1171 1599 1568
1906 1917 219 455
696 718 914 1154
407 562 1599 1749
1389 1535 744 1456
1791 1979 535 1206
597 670 389 111
131 171 1760 1858
770 928 1938 1633
1481 1537 1325 440
1667 1759 1038 837
869 1001 1114 1721
1523 1590 1412 1475
205 372 620 1395
1247 1396 113 1943
163 316 1852 ...

output:

Yes
00000000000000000000001000000000000001000010010000001010000000010000000000010100010000000000100100001001010110010101010011101101111001110001110110110001000110111110100111100011011110100100010101110010111100101111101001001001111111000111000111101000010111110111111101111111011110101111010110011111...

result:

ok accepted

Test #11:

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

input:

1000 37 46
174 204 1667 729
1866 1875 1884 556
792 945 1920 927
1303 1473 1163 1341
1519 1539 503 362
62 140 1262 1450
1235 1263 1031 1966
895 1057 215 1626
1135 1208 666 998
1459 1477 1941 1671
1050 1192 60 1375
137 244 1672 1445
217 414 724 1347
1043 1200 1401 68
1331 1495 919 933
1086 1137 1341 3...

output:

Yes
00000000000001000011100100001000000001100000100001000000110000011001111001000000011001000110010000000101001011011010001001100010101101101010100110000010111010101100111111111001111111001110000011101001011011101010111110111111011000011000001100111111001110111001010011111000110110111101111111011010...

result:

ok accepted

Test #12:

score: 0
Accepted
time: 398ms
memory: 387832kb

input:

50000 9 9
630 678 1889 1026
1568 1607 1637 114
732 830 1245 590
1023 1032 403 698
211 243 1531 1382
593 650 248 955
708 717 1688 1772
509 536 884 582
1798 1865 522 1714
333 390 75 1044
1494 1540 1320 1543
160 211 866 1215
1847 1906 1189 1636
154 198 1074 1193
1636 1705 227 1685
940 954 508 394
1266 ...

output:

Yes
00000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000001000000000100000000100000000000000000000000000000000000100000000000000001000010000000000000001000000000000000000000000000000000000000010000000000000000010000000000000000000000000000000010000...

result:

ok accepted

Test #13:

score: 0
Accepted
time: 422ms
memory: 387628kb

input:

50000 10 6
282 331 1148 1597
676 739 296 677
294 305 1501 1969
1440 1499 862 104
1008 1072 131 1387
1036 1053 915 1390
1569 1662 1463 996
287 334 1662 173
358 381 383 367
481 550 156 361
1340 1389 671 76
986 1006 1634 353
445 465 596 1864
1422 1452 1740 1762
1381 1407 745 4
1172 1188 144 1320
751 79...

output:

Yes
00000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000001000000000000010000000000000000000000000000000000000000000000000000000001000000000000000...

result:

ok accepted

Test #14:

score: 0
Accepted
time: 417ms
memory: 428264kb

input:

50000 7 15
107 197 820 713
1833 1863 671 1773
1573 1727 1976 1743
1656 1718 1714 926
1615 1734 113 378
182 285 1167 811
1924 1973 1809 178
972 1020 1877 100
25 46 1192 488
251 347 504 751
320 334 308 1545
554 619 166 1528
108 145 1283 1383
153 200 1714 494
390 537 1052 565
1331 1357 1638 327
87 161 ...

output:

No

result:

ok accepted

Test #15:

score: -100
Memory Limit Exceeded

input:

50000 130 164
26 1216 1021 1261
423 1110 383 616
772 1551 1399 245
42 811 1691 1783
28 1691 697 692
646 1607 1421 1684
312 1974 1671 86
212 905 73 226
149 517 215 924
1 1999 328 1453
1112 1934 831 1938
452 1041 1092 1108
752 1876 1394 1967
54 1919 1574 1188
1085 1608 502 1826
35 714 1023 312
191 655...

output:

No

result: