QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647602 | #5407. 基础图论练习题 | Astatinear | 60 | 264ms | 105460kb | C++14 | 1.6kb | 2024-10-17 14:53:28 | 2024-10-17 14:53:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int qpow[25000005];
int n;
bool flg[5005][5005];
int in[5005];
int bucket[5005];
int main()
{
int t;
scanf("%d", &t);
qpow[0] = 1;
for (int i = 1; i <= 5000 * 5000; ++i) qpow[i] = 1ll * qpow[i - 1] * 2 % mod;
while(t--)
{
int ans = 0;
scanf("%d", &n);
memset(in, 0, sizeof(in));
for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) flg[i][j] = false;
for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) flg[i][j] = true, in[i]++;
for (int i = 2; i <= n; ++i)
{
scanf("\n");
for (int j = 1; j <= ceil((i - 1) / 4.0); ++j)
{
int l = (j - 1) * 4 + 1, r = min(n, j * 4);
char now;
scanf("%c", &now);
int num;
if(now >= '0' && now <= '9') num = now - '0';
else num = now - 'A' + 10;
for (int j = l; j <= r; ++j) if(num & (1 << j - l)) flg[i][j] = true, flg[j][i] = false, in[i]++, in[j]--;
}
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= n; ++j)
{
if(!flg[i][j]) continue;
in[i]--, in[j]++;
for (int k = 0; k <= n; ++k) bucket[k] = 0;
for (int k = 1; k <= n; ++k) bucket[in[k]]++;
int now = 0, sum = 0, num = 0;
for (int k = 0; k <= n; ++k)
{
for (int l = 1; l <= bucket[k]; ++l)
{
++num;
sum += k;
now += sum == (num * (num - 1)) / 2;
}
}
ans += 1ll * qpow[(max(i, j) - 2) * (max(i, j) - 1) / 2 + min(i, j) - 1] * now % mod;
ans %= mod;
in[i]++, in[j]--;
}
}
cout << ans << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 103ms
memory: 103688kb
input:
10000 100 1 2 2 8 C0 F0 27 78 AE1 C01 511 D87 EF20 3873 2742 73D0 DC9B0 FB2A3 9C011 9B4E0 95DC00 A7B980 F43531 6A6245 5347BE0 1A6C8A1 88E46D6 64CF3AE D25F63C1 C894E4C3 1C0AFD73 EC1C3F9A 087CE17C0 22149A380 B28038AF1 B9CA21C7F D78F5307C1 49045489A2 72C4DE6FD1 7713F40D05 EEE8878EEC1 310E62812B1 DA9D5B...
output:
281603732 13 285212672 371842543 84 0 1983 2 268505087 268435455 719476515 32785 2 719476771 123 2621567 2523 0 719476275 371842543 2097159 41087 34815 3113984 719478307 502774846 719476267 719476259 719476259 65224 268697613 719477283 36863 2171007 719476259 371842543 120 84 219 5769215 268435455 1...
result:
ok 10000 numbers
Test #2:
score: 20
Accepted
time: 100ms
memory: 103020kb
input:
10000 100 0 2 1 8 41 F2 30 30 F60 7D2 605 024 E910 45F3 3CB0 3B88 0FE21 A7DF3 3B162 70D7A 70B9C1 DFB731 883B33 930FC6 4F8BEC1 CC73551 1A344F3 88966C9 3879FE20 93839630 B6C3FF85 F6D5F7B1 F757DCB20 63C3512A3 9BFD99935 ED1E4F248 ECAB4DA041 EA5CE54511 EA07C72263 F8ADE1FD8C B220226E1F0 34F274277A0 4A1A14...
output:
281603732 2097151 0 144 268443647 32767 2097151 2 19 903009902 0 268435455 1103 1099 268501119 719476259 17 574715508 0 268435455 321515202 1023 745417303 84 2097151 371842543 301989887 272629791 268435455 153406 0 719476531 2 3368 132695 0 402653183 268435455 371842543 0 0 17 719476259 371842543 23...
result:
ok 10000 numbers
Test #3:
score: 20
Accepted
time: 123ms
memory: 102700kb
input:
10000 100 1 0 3 7 11 C1 71 1A C01 E43 237 9B5 33C1 0DE3 7C74 B042 38E60 65480 1D103 862A7 B2DA80 C63273 CF8AD3 AFBDC2 2816D11 1B12351 1869CC5 6BC6DB3 50E5FAB1 4E291CB2 4DF82716 0D410C3E FD4B31250 8BF2C54A0 1266235D1 757755C58 724DFD1960 F6D1285122 281CDE0BB1 5EF924A6A9 786A08B90C1 BE8C674EE52 B9EFA2...
output:
281603732 371842549 371842543 268435459 1281 371842543 719476259 371842543 84 60934 108 2 268435455 108 1159 108 2097663 2 371842543 719476259 2 371842543 1536 7288681 269746175 371842543 268435463 2 371842543 0 899345324 84 1183 0 19 93 371842543 21 21 21 1152 371842543 780828798 268435455 71947625...
result:
ok 10000 numbers
Test #4:
score: 20
Accepted
time: 122ms
memory: 102684kb
input:
10000 100 0 0 1 3 D1 D0 B4 DD 940 C13 2C3 62A E900 2FC1 2470 E6EE 80151 912A3 CADA5 7F6D3 0CB410 E17771 686F85 68DFEE FABD991 150D7A2 90C8247 5B06F87 46894CE0 42575142 BC2873D5 8F1E0A9C D26EDC921 30F8DCAA2 6ECD63697 C739CFD42 631139F800 A57ED99C72 20B0B17882 347727E7CA E619F1E8A91 1DC6F46E610 01C38C...
output:
281603732 21 371842543 2 102 102 0 268435455 1536 17 719476259 2 2 371842543 2621443 32767 2 21 371842543 189 719476259 1035 1087 2097151 0 719476259 2 2 268435455 0 21 144 719476259 2 1023 32767 2097151 32775 719476259 371842543 0 36863 21 2097151 2 32767 268435455 2 32768 180 21 123 371842543 93 3...
result:
ok 10000 numbers
Test #5:
score: 20
Accepted
time: 126ms
memory: 102984kb
input:
10000 100 1 3 3 C A1 A2 96 AA 9D1 A01 C16 EDD 2560 D652 0990 0630 1CCF0 6FCD0 FF216 A1AE4 733020 7287D3 E64A46 ADA8C2 AD3E2A0 02BC872 6D92D01 05C5759 33F30180 D42829D1 42734D77 01C7FE14 047CF2770 AE654B450 8C50339E5 AABDF020C 92316BB5E0 4E2EA0A9E2 3C962A0C27 9956ED19E9 458EFDCCCC0 0B1BC934520 5B83A4...
output:
281603732 21 2359295 719476259 105 0 268435455 2113543 33023 21 2 0 0 32847 2097151 405396975 21 371842543 2162687 268435455 84 371842543 105 32767 3343 268435455 371842543 719476259 0 32895 2 719476259 21 2 21 21 21 21 21 21 21 171 2621439 268959743 2113791 108 2 32767 268435487 268435463 32840 78 ...
result:
ok 10000 numbers
Test #6:
score: 20
Accepted
time: 121ms
memory: 105336kb
input:
10000 100 1 3 0 7 D1 82 10 3D E60 EE2 0B1 5A5 10C0 B543 0AD3 1390 45750 C6830 0EAB5 B2D55 FF2090 503CC2 0BB701 EB004B 3FDD210 17A52F1 44B5255 7418726 75843761 150CEF50 F20F26E6 8FBBA768 D24A5D161 AA31E8A90 373E9FE24 D32AA0A0A F4C90F3500 6C36C6F8C3 726D14EF35 CFC549657E 10803BE30D1 4DF734243E0 FF192B...
output:
281603732 0 2375679 21 21 2097151 2098207 21 2 2097151 0 0 2 84 0 32767 268435455 2 21 2097279 1040 2 268435455 93 2097151 2097151 105 719476259 2170879 36863 268435455 371842543 268435455 719476259 719476259 102 0 371842543 2 21 1535 1025 21 371842543 2 371842543 0 371842543 21 1033 21 371842543 17...
result:
ok 10000 numbers
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 20
Accepted
time: 133ms
memory: 102868kb
input:
10000 300 1 0 5 7 B1 C2 26 32 DA0 243 682 E2E D4B1 DFD3 60C3 4D66 826E1 D8511 AFC36 254F4 EC8F70 F5B480 7DEA20 06DF55 3EA08A1 C6B5463 C9B2C45 544D18E 2693C7C0 31E27182 D31059D1 BE767720 AC55C6D80 A21839A80 AE17E0DD6 772EF61A9 66EE846D51 B19BE410D0 03A8D64927 3297B9C9DC 05E209071C0 0A327E1EBE2 7C4427...
output:
713679823 719476259 189 2236927 2097151 380231151 1280 33407 21 2 404226047 268435455 2 177 13 371842543 180 268435455 418322861 120 32879 138 19 0 2098175 21 91318796 268435455 219 371842544 719476262 666809811 32775 2255 36967 21 21 32769 32783 2164735 719476259 371842543 13 2105343 462361576 2627...
result:
ok 10000 numbers
Test #8:
score: 20
Accepted
time: 136ms
memory: 105428kb
input:
10000 300 1 3 7 D 70 A0 97 D2 581 D73 FE3 ADE BE90 2C00 0FD0 1ADD 9D7E1 85380 8D154 1C3E1 4091C1 835721 16A5A0 A579FF 3338C21 4C5BC41 B3267C0 481D2E5 C045A400 D2330C70 AA7E1366 ED783C80 5D9C8EB61 A20944E71 2F2CCB6F4 AB4C91E62 FABB51BF80 41ED063E43 C54DCF1D52 4B12739A29 9F98B9E4760 927BF482451 E8BFD2...
output:
713679823 268435459 62321207 128701157 120 123 3145743 2 371842543 33926 2 2 61146 2 268435455 1287 371842543 2 140217 719541795 1043 36863 61689 719476515 2097279 192 2143 0 780828798 0 219 162 1223 0 2603 12411540 33886 91318796 0 32767 171 0 268435455 21 2097151 21 373939695 256347164 371842547 7...
result:
ok 10000 numbers
Test #9:
score: 20
Accepted
time: 136ms
memory: 105264kb
input:
10000 300 1 3 3 A D0 D0 76 31 710 D91 4F7 A42 F3B1 6AA2 71F0 F751 CB4B0 30362 8EB94 C1913 532281 59FF53 9C2B57 3DCF3B BA00450 6E6FE40 76F7C50 4EE1E71 0FBA9391 D3C71DA3 2E925076 A44C773E F02E9DFB1 DC7535EE3 90DAF35E7 784F6A354 409869FC20 9C10BEAFB1 0EE9879CC0 EE8886BEEA CE586A8E371 08003AF5E92 FAB058...
output:
713679823 0 2655231 177 719476259 2130942 2097151 84 371842543 13 719476259 2 1107 17 21 2 786585123 268435455 93 13 69121 268435455 108 2 719476259 21 2363391 719476259 2621439 719476259 17 2 371842543 719492643 719476259 2 371842543 32767 0 49407 2 268435455 719476259 49155 339738623 40970 19 2 0 ...
result:
ok 10000 numbers
Test #10:
score: 20
Accepted
time: 138ms
memory: 105424kb
input:
10000 300 1 2 0 B A0 42 A7 C3 3B0 310 4B0 E7D 4421 9AB2 BBB2 5C0B 932B1 96EF3 12742 15A3C CDCC71 729330 1B7FD3 5C8E8B F431B00 C2E9C11 86FE105 2A2516D 376B4CA0 432EA5A1 A5EB6871 39A6E061 D93C4F551 C75FF9432 80CC17881 62FF560ED DB75889331 6D4C06F682 ABDA809031 AA8BE151AF FDA74DF05B1 9BBFF121F21 37DD84...
output:
713679823 371842543 219 123 13 268435455 1159 2047 0 2097151 2097151 78 719476259 19 719476259 78 719476259 0 32767 0 2097663 1023 2 19 21 1071 0 268435455 268435455 81 0 1151 0 719476259 268435455 268435459 0 2047 719476259 2 371842543 1055 719476259 21 49167 719476259 719476259 21 268435455 102 0 ...
result:
ok 10000 numbers
Test #11:
score: 20
Accepted
time: 151ms
memory: 104588kb
input:
10000 300 0 1 2 5 21 E3 E7 86 C31 AE2 604 3AD BD21 7532 7D50 4062 FC4C0 14321 D2F02 04FC5 930270 D2F1C3 C4B331 3E6C9D 14B2D91 D4DB863 972E643 704C878 44068510 30CC1B10 60027D91 ECF452A6 3DC3A8021 208B1B201 BE704CBC0 D7B215102 4B2067BFC0 93203D7A02 D6859EAB12 9A1DA02E88 C1256A2BBE1 7959F7570A2 03AD40...
output:
713679823 2 0 1055 21 371842543 34847 2 1039 21 21 36863 723670563 268435455 21 81 0 371842543 719476259 719476323 719476259 21 371842543 2097151 2 0 38419 21 2097153 84 371842543 268435455 2097151 1287 2099199 0 2097151 371842543 371842671 853693987 268435463 2621439 268435455 33279 21 371842543 21...
result:
ok 10000 numbers
Test #12:
score: 20
Accepted
time: 151ms
memory: 105228kb
input:
10000 300 1 3 1 D C1 C0 81 CE 6D1 8F0 E03 DF8 9811 1062 6977 A4A8 35BD0 A8A22 896E7 AC529 E6A321 DFB152 BA0EF1 201971 22B6670 D9B2A33 5456C01 624F7BC 5D70CF31 2DF2CEE2 A281DE17 4259303C FC2738E01 FE7D9DE22 5D66F93C4 48F91AB50 DC6EE7EC10 FF7C2E2AB0 CCE40C2874 C463A3A01F 79687341061 E63184689B1 CE3739...
output:
713679823 32768 171 1041 2 371842543 371842543 2 2097151 1047 268435455 1159 177 21 2 2097151 0 270532607 171 2105343 268435455 2 0 0 2 123 35071 719476259 120 2 1023 2097151 21 93 2097151 2097159 719476259 1023 2 719476259 1023 1537 0 2097151 268435455 268435455 0 2097151 21 371842543 2 49159 0 78 ...
result:
ok 10000 numbers
Subtask #3:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #13:
score: 20
Accepted
time: 231ms
memory: 105324kb
input:
10000 500 1 0 1 D 00 52 64 DC 651 C83 3D5 81F C280 5D02 A006 69BA F9170 ED933 600D4 F1224 8A7760 6692B3 C724E5 A84AEE DE9D551 BA075F0 004A075 0CB2132 200D6780 BC8227B2 E253F4C6 DE92ECBB 324EB89A0 394E85723 AD1B83763 AC28DAAE3 42480D89C1 9E82EECD13 EDCB865053 F8505D00E7 5966982D421 1369B1238A2 0C7886...
output:
731931765 464803179 0 0 167068 371842543 213 2 3657 268959875 64723 19 105 2 2170879 2 1167 49231 371843567 2 0 21 268435455 225 2 19 2528 371842543 720524835 268470271 268435455 13 793218204 371842543 276824063 2162687 1287 532608873 123 4058978 19 2 102 14443520 84 371842543 719476259 2146567 123 ...
result:
ok 10000 numbers
Test #14:
score: 20
Accepted
time: 261ms
memory: 105176kb
input:
10000 500 1 1 7 E C0 83 01 F2 430 7B1 4C2 F69 79B0 BAB0 8501 ED04 623C1 44270 28EA1 6951B D800E1 6AAE23 3E4700 2951CF FC6A2E1 88EC680 CB91BD0 3C1B2D7 E0506900 5E9881F1 EFCEF6B1 F43AD3AD AFB842AD0 854FD0EF1 0605F2662 8159FD734 4A0462E631 7C8D1C73C3 25E9002DD3 F6A1C7872A C318B9CF590 AC0AB582702 683C03...
output:
731931765 32791 371842543 961777079 0 2097151 2 0 2 2 405396975 371850735 0 17 132 0 0 13 719476771 371842543 268697599 371842543 2097151 144 2099455 84 1183 108 0 1791 2 0 719476259 168451700 1143 0 222 180 84 485458942 180 371842543 93 268505087 721606179 371842543 2 3114046 371842543 719476263 71...
result:
ok 10000 numbers
Test #15:
score: 20
Accepted
time: 240ms
memory: 105440kb
input:
10000 500 0 0 4 C 61 91 F5 72 850 1F0 1C7 198 0C50 8EC1 5703 41D7 96610 65C50 E1353 BC830 BE9C61 B56811 7DD2B7 CAA09D 32F3451 768A221 3E9FB81 87BC19E 6A1A9371 E754F460 229B4E01 BA918ED6 22F435311 9A9055D01 7BE24D815 688E46D63 2EF15F69A1 BD076C4272 8F060DFEB1 7E0E9F450C 36F83622141 4D146501601 DFC62B...
output:
731931765 719476259 2 719476259 21 32767 2 1056 268435455 102 0 21 719476259 32775 32767 0 2097215 2 0 371842543 0 1599 102 21 534739891 17 2 3718206 1671 719476259 371842543 2162687 1023 21 19 1536 2 1295 2 0 0 3685438 2 105 371842543 2361343 2098179 719476259 2 36927 268435455 32771 719476259 7194...
result:
ok 10000 numbers
Test #16:
score: 20
Accepted
time: 252ms
memory: 105460kb
input:
10000 500 1 1 6 C 70 91 43 C8 751 DB0 475 B65 02D1 11C0 DFD0 735A BAEB1 89142 BCB77 ACE59 C2FF20 B6CAD0 39DED4 DB1867 9507A20 DB3B4D2 CCC9E84 E32626F 1230A770 44DBE282 0A852D36 D0BDC9D9 766834570 C7DB0AAE1 EE8F99502 F142EE706 90B1FEC591 8B2FF38D82 B2FC398E97 E4BBD7874F 35A957E9AC0 8E65891D891 2BD857...
output:
731931765 719476259 32831 2097151 34815 0 32767 2 2113535 276824063 268435455 2097407 719476259 268435455 0 177 0 2 2 719476259 268435455 21 2 2 2097151 0 21 33279 1025 0 2 371842543 0 21 225 268435455 1539 81 371842543 2097151 33283 0 78 1539 2101247 371842543 1543 2 1159 2 2 21 719476259 719476259...
result:
ok 10000 numbers
Test #17:
score: 20
Accepted
time: 264ms
memory: 105264kb
input:
10000 500 0 1 4 1 D1 C1 C3 8F 110 971 2F3 E54 38F0 0331 6C44 7C86 E6090 B2DF2 C4576 18921 68C3E1 29C5F0 62B6A4 396B00 96D71A0 14A9872 A1D75D2 2BBD5BA 162F2F50 2A3806A0 25E4C1D2 653257DD 0FF494901 A9C278C32 FB5AAF7E6 E9CE9172B D332B7FBD1 936CF94A90 85ECF6BC16 9E128C7838 8CF618E4420 59778EA0A01 E68623...
output:
731931765 0 2113567 2 0 371842543 268435459 1669 371842543 719476259 33823 719476259 32771 371846639 1063 371842543 21 1280 719476259 21 0 171 719476259 2 2098183 0 2097151 32771 2 0 33151 42176 2 2097153 2097183 719476259 268435455 0 123 786585131 21 268437503 371842543 2 2 1023 0 2 2 1608 2424895 ...
result:
ok 10000 numbers
Test #18:
score: 20
Accepted
time: 244ms
memory: 105264kb
input:
10000 500 1 3 7 7 C0 23 F3 C1 B71 A63 713 AE0 CC11 ADA1 D524 D9D4 8CC31 0F420 69C50 99AE4 9E3BB0 0F4703 A500E5 E9E696 FDD5900 08F3913 FF7EEA6 9A94F58 D6D968D1 E9908093 8E0616A4 B6630A50 4B55F67A1 38DF7BC12 22F514233 DEB02DCC7 794208B8F0 AD3469EB32 F3A8349666 E43B434544 16FBC8DF851 62F0A44AE53 C83474...
output:
731931765 40959 371842543 1056 21 93 2097155 1159 0 2097151 0 2 2097151 108 2097151 32767 1287 1279 0 81 32767 2 719476259 0 32767 719476259 32783 2097151 177 1155 268435455 1071 2 2097151 371842543 0 268435455 21 0 2 2 120 21 2 32767 32767 2097155 2051 719476259 32767 371842543 144 371842543 2 2097...
result:
ok 10000 numbers
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #19:
score: 0
Time Limit Exceeded
input:
10000 1500 0 2 7 2 C1 A1 62 45 601 472 201 5D0 5800 1861 4171 2EC4 A14C0 553B3 8E644 8268A D29BB1 961990 10ECB1 16F48F F152360 55711D3 B9B4643 50FAFC0 A7D5EA10 7BE77013 C1907CC7 FD610245 690ACF6F0 963E3E152 7DDADE887 4037FD164 3FFB819E11 6A08950852 3968246D26 19A75C9E9D 401FBCA3380 88072D9D331 9B877...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
0%