QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188091 | #2793. 萌萌哒 | zlxFTH | 100 ✓ | 79ms | 9756kb | C++14 | 1.2kb | 2023-09-25 13:52:06 | 2023-09-25 13:52:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int P = 1e9 + 7;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M;
cin >> N >> M;
vector<array<int, 17>> fa(N);
for (int j = 0; j < 17; j++) {
for (int i = 0; i + (1 << j) <= N; i++) {
fa[i][j] = i;
}
}
auto find = [&](int u, int k) {
while (fa[u][k] != u) {
u = fa[u][k] = fa[fa[u][k]][k];
}
return u;
};
auto merge = [&](int u, int v, int k) {
u = find(u, k);
v = find(v, k);
fa[u][k] = v;
};
while (M--) {
int l1, r1, l2, r2;
cin >> l1 >> r1 >> l2 >> r2;
l1--, r1--, l2--, r2--;
for (int j = 16; ~j; j--) {
if (l1 + (1 << j) - 1 <= r1) {
merge(l1, l2, j);
l1 += 1 << j;
l2 += 1 << j;
}
}
}
for (int j = 16; j; j--) {
for (int i = 0; i + (1 << j) <= N; i++) {
int u = find(i, j);
merge(i, u, j - 1);
merge(i + (1 << j - 1), u + (1 << j - 1), j - 1);
}
}
int ans = 1;
for (int i = 0; i < N; i++) {
if (fa[i][0] == i) {
ans = i64(ans) * (ans == 1 ? 9 : 10) % P;
}
}
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 0ms
memory: 3432kb
input:
2000 1999 533 678 1272 1417 56 228 679 851 1807 1990 726 909 1994 1995 1906 1907 737 738 970 971 1804 1805 457 458 149 150 684 685 1181 1182 683 684 7 8 1810 1811 271 272 1460 1461 1829 1830 1183 1184 1289 1290 904 905 418 419 1259 1260 1200 1201 520 521 1574 1575 1350 1351 818 819 335 336 725 726 1...
output:
999969137
result:
ok single line: '999969137'
Test #2:
score: 10
Accepted
time: 1ms
memory: 3544kb
input:
2000 2000 1 30 1 30 1 30 31 60 1 30 61 90 1 30 91 120 1 30 121 150 1 30 151 180 1 30 181 210 1 30 211 240 1 30 241 270 1 30 271 300 1 30 301 330 1 30 331 360 1 30 361 390 1 30 391 420 1 30 421 450 1 30 451 480 1 30 481 510 1 30 511 540 1 30 541 570 1 30 571 600 1 30 601 630 1 30 631 660 1 30 661 690...
output:
913000028
result:
ok single line: '913000028'
Test #3:
score: 10
Accepted
time: 36ms
memory: 9740kb
input:
100000 100000 1 2 20001 20002 3 4 20001 20002 20001 20002 30001 30002 20001 20002 30003 30004 5 6 20003 20004 7 8 20003 20004 20003 20004 30005 30006 20003 20004 30007 30008 9 10 20005 20006 11 12 20005 20006 20005 20006 30009 30010 20005 20006 30011 30012 13 14 20007 20008 15 16 20007 20008 20007 2...
output:
251421667
result:
ok single line: '251421667'
Test #4:
score: 10
Accepted
time: 25ms
memory: 9756kb
input:
100000 100000 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 17 17 17 17 18 18 18 18 19 19 19 19 20 20 20 20 21 21 21 21 22 22 22 22 23 23 23 23 24 24 24 24 25 25 25 25 26 26 26 26 27 27 27 2...
output:
38266700
result:
ok single line: '38266700'
Test #5:
score: 10
Accepted
time: 37ms
memory: 9728kb
input:
100000 99999 57175 59130 60825 62780 24573 25575 95374 96376 12821 14028 96304 97511 5907 7888 83136 85117 75225 76784 30470 32029 41612 42768 38870 40026 59844 61464 7575 9195 164 1867 72343 74046 75579 76941 65723 67085 81974 83382 76150 77558 61275 61276 71770 71771 41022 41023 53252 53253 38966 ...
output:
488529801
result:
ok single line: '488529801'
Test #6:
score: 10
Accepted
time: 74ms
memory: 9740kb
input:
100000 100000 56924 98065 620 41761 36521 52800 46068 62347 52950 74016 45389 66455 46096 64674 59335 77913 46574 50030 84295 87751 13954 64931 1367 52344 2861 85278 16911 99328 38092 99048 686 61642 83328 93974 1001 11647 12019 98366 10164 96511 42343 85279 30945 73881 52386 94769 39732 82115 12640...
output:
90
result:
ok single line: '90'
Test #7:
score: 10
Accepted
time: 79ms
memory: 9744kb
input:
100000 100000 67586 87935 8765 29114 12611 97200 9223 93812 84451 96669 51827 64045 40764 77657 51008 87901 1064 28589 1715 29240 67662 89304 25630 47272 1102 11229 13107 23234 20145 47011 40456 67322 34819 85540 1711 52432 23833 46749 74260 97176 67061 86360 57203 76502 2316 99268 941 97893 10261 7...
output:
405943760
result:
ok single line: '405943760'
Test #8:
score: 10
Accepted
time: 36ms
memory: 9740kb
input:
100000 100000 1 200 1 200 1 200 201 400 1 200 401 600 1 200 601 800 1 200 801 1000 1 200 1001 1200 1 200 1201 1400 1 200 1401 1600 1 200 1601 1800 1 200 1801 2000 1 200 2001 2200 1 200 2201 2400 1 200 2401 2600 1 200 2601 2800 1 200 2801 3000 1 200 3001 3200 1 200 3201 3400 1 200 3401 3600 1 200 360...
output:
168104504
result:
ok single line: '168104504'
Test #9:
score: 10
Accepted
time: 35ms
memory: 9744kb
input:
100000 100000 1 200 1 200 1 200 201 400 1 200 401 600 1 200 601 800 1 200 801 1000 1 200 1001 1200 1 200 1201 1400 1 200 1401 1600 1 200 1601 1800 1 200 1801 2000 1 200 2001 2200 1 200 2201 2400 1 200 2401 2600 1 200 2601 2800 1 200 2801 3000 1 200 3001 3200 1 200 3201 3400 1 200 3401 3600 1 200 360...
output:
168104504
result:
ok single line: '168104504'
Test #10:
score: 10
Accepted
time: 0ms
memory: 3424kb
input:
2000 2000 1 2 601 602 3 4 601 602 601 602 901 902 601 602 903 904 5 6 603 604 7 8 603 604 603 604 905 906 603 604 907 908 9 10 605 606 11 12 605 606 605 606 909 910 605 606 911 912 13 14 607 608 15 16 607 608 607 608 913 914 607 608 915 916 17 18 609 610 19 20 609 610 609 610 917 918 609 610 919 920...
output:
488322317
result:
ok single line: '488322317'