QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246914 | #7629. Make SYSU Great Again II | ucup-team022# | AC ✓ | 220ms | 36516kb | C++17 | 1.9kb | 2023-11-11 12:03:01 | 2023-11-11 12:03:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[2050][2050], b[2050], m, ans[2050], used[2050], L, OK, c[2050];
void dfs(int x) {
if (OK) return;
if (x == L + 1) {
// cerr << "AA ";
// for (int i = 1; i <= L; i++) cerr << b[ans[i]] << ' ';
// cerr << '\n';
OK = 1;
return;
}
for (int i = m; i >= 1; i--) {
if (used[i]) continue;
if (b[i] & b[ans[x - 1]]) continue;
ans[x] = i;
if (x == L && (b[i] & b[ans[1]])) continue;
used[i] = 1, dfs(x + 1);
used[i] = 0;
if (OK) return;
}
}
int cnt[20000005];
bool Bad(int x, int y) {
if (x > 0 && (a[x][y] & a[x - 1][y])) return 1;
if (y > 0 && (a[x][y] & a[x][y - 1])) return 1;
if ((a[x][y] & a[x + 1][y])) return 1;
if ((a[x][y] & a[x][y + 1])) return 1;
return 0;
}
int main() {
int n;
cin >> n;
int t = 1;
while (t < n) t = 2 * t;
for (int i = 0; i < t; i++) {
if (__builtin_popcount(i) <= (t > 500 ? 6 : (t > 120 ? 5 : (t > 60 ? 4 : 3)))) b[++m] = i;
}
L = t / 2;
dfs(1);
for (int i = 0; i < t / 2; i++) {
c[i] = c[i + t / 2] = b[ans[i + 1]];
}
for (int i = 0; i < t / 2; i++) {
for (int j = 0; j < t; j++) {
a[i][j] = c[(i + j) % t] + c[(j - i + t) % t] * t;
}
}
for (int j = 0; j < t; j++) {
a[t / 2][j] = c[(t / 2 + j) % t];
}
for (int i = t / 2 + 1; i < t; i++) {
for (int j = 0; j < t; j++) {
a[i][j] = c[(i + j) % t] + c[(j - i + t + 1) % t] * t;
}
}
for (int i = 0; i < t; i++) {
for (int j = 0; j < t; j++) {
cnt[a[i][j]]++;
}
}
for (int j = t / 2; j < t; j++) {
cnt[a[t / 2][j]]--;
}
for (int j = t / 2; j < t; j++) {
a[t / 2][j] = 0;
while (cnt[a[t / 2][j]] == 5 || Bad(t / 2, j)) a[t / 2][j]++;
cnt[a[t / 2][j]]++;
}
puts("Yes");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j] << ' ';
}
cout << '\n';
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3408kb
input:
4
output:
Yes 15 0 15 0 0 15 0 15 3 0 1 16 12 3 12 3
result:
ok 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3388kb
input:
1
output:
Yes 0
result:
ok 1
Test #3:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
2
output:
Yes 0 0 0 0
result:
ok 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3400kb
input:
3
output:
Yes 15 0 15 0 15 0 3 0 1
result:
ok 1
Test #5:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
5
output:
Yes 54 9 36 0 54 1 52 8 38 1 36 0 54 9 36 8 38 1 52 8 6 1 4 0 2
result:
ok 1
Test #6:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
8
output:
Yes 54 9 36 0 54 9 36 0 1 52 8 38 1 52 8 38 36 0 54 9 36 0 54 9 8 38 1 52 8 38 1 52 6 1 4 0 2 16 2 8 49 12 32 6 49 12 32 6 4 48 14 33 4 48 14 33 32 6 49 12 32 6 49 12
result:
ok 1
Test #7:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
13
output:
Yes 238 17 204 51 136 102 153 0 238 17 204 51 136 1 236 19 200 54 137 96 158 1 236 19 200 54 156 3 232 22 201 48 142 97 156 3 232 22 201 99 152 6 233 16 206 49 140 99 152 6 233 16 136 102 153 0 238 17 204 51 136 102 153 0 238 54 137 96 158 1 236 19 200 54 137 96 158 1 201 48 142 97 156 3 232 2...
result:
ok 1
Test #8:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
21
output:
Yes 924 99 792 231 528 462 561 396 627 264 726 297 660 363 132 66 924 99 792 231 528 67 920 103 784 238 529 460 563 392 630 265 724 299 644 354 156 67 920 103 784 238 152 71 912 110 785 236 531 456 566 393 628 267 708 290 668 355 152 71 912 110 785 359 144 78 913 108 787 232 534 457 564 395 612 2...
result:
ok 1
Test #9:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
34
output:
Yes 3900 195 3640 455 3120 975 2080 1950 2145 1820 2275 1560 2535 1040 2990 1105 2860 1235 2600 1495 520 3510 585 3380 715 2340 1755 260 3770 325 3250 65 3900 195 67 3896 199 3632 463 3104 990 2081 1948 2147 1816 2279 1552 2542 1041 2988 1107 2856 1239 2568 1526 521 3508 587 3364 731 2308 1786 261 ...
result:
ok 1
Test #10:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
55
output:
Yes 3900 195 3640 455 3120 975 2080 1950 2145 1820 2275 1560 2535 1040 2990 1105 2860 1235 2600 1495 520 3510 585 3380 715 2340 1755 260 3770 325 3250 65 3900 195 3640 455 3120 975 2080 1950 2145 1820 2275 1560 2535 1040 2990 1105 2860 1235 2600 1495 520 3510 585 67 3896 199 3632 463 3104 990 2081 ...
result:
ok 1
Test #11:
score: 0
Accepted
time: 2ms
memory: 3924kb
input:
89
output:
Yes 15996 387 15480 903 14448 1935 12384 3999 8256 7998 8385 7740 8643 7224 9159 6192 10191 4128 12126 4257 11868 4515 11352 5031 10320 6063 2064 14190 2193 13932 2451 13416 2967 9288 7095 1032 15222 1161 14964 1419 12900 3483 8772 7611 516 15738 645 14706 1677 12642 3741 8514 7869 258 15609 774 145...
result:
ok 1
Test #12:
score: 0
Accepted
time: 1ms
memory: 4156kb
input:
100
output:
Yes 15996 387 15480 903 14448 1935 12384 3999 8256 7998 8385 7740 8643 7224 9159 6192 10191 4128 12126 4257 11868 4515 11352 5031 10320 6063 2064 14190 2193 13932 2451 13416 2967 9288 7095 1032 15222 1161 14964 1419 12900 3483 8772 7611 516 15738 645 14706 1677 12642 3741 8514 7869 258 15609 774 145...
result:
ok 1
Test #13:
score: 0
Accepted
time: 3ms
memory: 5816kb
input:
200
output:
Yes 63736 1799 61680 3855 57568 7967 49344 15934 49601 15420 50115 14392 51143 12336 52942 12593 52428 13107 51400 14135 34952 30326 35209 29812 35723 28784 36751 24672 40606 24929 40092 25443 39064 26471 37008 28270 37265 27756 37779 26728 38807 18504 46774 18761 46260 19275 45232 20303 41120 24158...
result:
ok 1
Test #14:
score: 0
Accepted
time: 13ms
memory: 10916kb
input:
300
output:
Yes 258552 3591 254448 7695 246240 15903 229824 32319 196992 64638 197505 63612 198531 61560 200583 57456 204687 49248 212382 49761 211356 50787 209304 52839 205200 56943 139536 122094 140049 121068 141075 119016 143127 114912 147231 98496 163134 99009 162108 100035 160056 102087 155952 106191 14774...
result:
ok 1
Test #15:
score: 0
Accepted
time: 19ms
memory: 9104kb
input:
400
output:
Yes 258552 3591 254448 7695 246240 15903 229824 32319 196992 64638 197505 63612 198531 61560 200583 57456 204687 49248 212382 49761 211356 50787 209304 52839 205200 56943 139536 122094 140049 121068 141075 119016 143127 114912 147231 98496 163134 99009 162108 100035 160056 102087 155952 106191 14774...
result:
ok 1
Test #16:
score: 0
Accepted
time: 16ms
memory: 9908kb
input:
500
output:
Yes 258552 3591 254448 7695 246240 15903 229824 32319 196992 64638 197505 63612 198531 61560 200583 57456 204687 49248 212382 49761 211356 50787 209304 52839 205200 56943 139536 122094 140049 121068 141075 119016 143127 114912 147231 98496 163134 99009 162108 100035 160056 102087 155952 106191 14774...
result:
ok 1
Test #17:
score: 0
Accepted
time: 18ms
memory: 16236kb
input:
600
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #18:
score: 0
Accepted
time: 24ms
memory: 16312kb
input:
700
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #19:
score: 0
Accepted
time: 36ms
memory: 17552kb
input:
800
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #20:
score: 0
Accepted
time: 49ms
memory: 17604kb
input:
900
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #21:
score: 0
Accepted
time: 56ms
memory: 18304kb
input:
1000
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #22:
score: 0
Accepted
time: 97ms
memory: 36404kb
input:
1200
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #23:
score: 0
Accepted
time: 109ms
memory: 36296kb
input:
1400
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #24:
score: 0
Accepted
time: 153ms
memory: 36316kb
input:
1600
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #25:
score: 0
Accepted
time: 173ms
memory: 36324kb
input:
1800
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #26:
score: 0
Accepted
time: 183ms
memory: 36316kb
input:
1900
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #27:
score: 0
Accepted
time: 199ms
memory: 36336kb
input:
1920
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #28:
score: 0
Accepted
time: 220ms
memory: 36340kb
input:
2000
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #29:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
62
output:
Yes 3900 195 3640 455 3120 975 2080 1950 2145 1820 2275 1560 2535 1040 2990 1105 2860 1235 2600 1495 520 3510 585 3380 715 2340 1755 260 3770 325 3250 65 3900 195 3640 455 3120 975 2080 1950 2145 1820 2275 1560 2535 1040 2990 1105 2860 1235 2600 1495 520 3510 585 3380 715 2340 1755 260 3770 325 67 ...
result:
ok 1
Test #30:
score: 0
Accepted
time: 0ms
memory: 8596kb
input:
130
output:
Yes 63736 1799 61680 3855 57568 7967 49344 15934 49601 15420 50115 14392 51143 12336 52942 12593 52428 13107 51400 14135 34952 30326 35209 29812 35723 28784 36751 24672 40606 24929 40092 25443 39064 26471 37008 28270 37265 27756 37779 26728 38807 18504 46774 18761 46260 19275 45232 20303 41120 24158...
result:
ok 1
Test #31:
score: 0
Accepted
time: 2ms
memory: 4004kb
input:
126
output:
Yes 15996 387 15480 903 14448 1935 12384 3999 8256 7998 8385 7740 8643 7224 9159 6192 10191 4128 12126 4257 11868 4515 11352 5031 10320 6063 2064 14190 2193 13932 2451 13416 2967 9288 7095 1032 15222 1161 14964 1419 12900 3483 8772 7611 516 15738 645 14706 1677 12642 3741 8514 7869 258 15609 774 145...
result:
ok 1
Test #32:
score: 0
Accepted
time: 0ms
memory: 5908kb
input:
66
output:
Yes 15996 387 15480 903 14448 1935 12384 3999 8256 7998 8385 7740 8643 7224 9159 6192 10191 4128 12126 4257 11868 4515 11352 5031 10320 6063 2064 14190 2193 13932 2451 13416 2967 9288 7095 1032 15222 1161 14964 1419 12900 3483 8772 7611 516 15738 645 14706 1677 12642 3741 8514 7869 258 15609 774 145...
result:
ok 1
Test #33:
score: 0
Accepted
time: 51ms
memory: 16284kb
input:
1021
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #34:
score: 0
Accepted
time: 48ms
memory: 16740kb
input:
1022
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #35:
score: 0
Accepted
time: 49ms
memory: 16112kb
input:
1023
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #36:
score: 0
Accepted
time: 57ms
memory: 18056kb
input:
1024
output:
Yes 1033200 15375 1016800 31775 984000 64575 918400 129150 919425 127100 921475 123000 925575 114800 932750 115825 930700 117875 926600 121975 795400 252150 796425 250100 798475 246000 802575 229600 817950 230625 815900 232675 811800 236775 803600 243950 804625 241900 806675 237800 810775 205000 842...
result:
ok 1
Test #37:
score: 0
Accepted
time: 79ms
memory: 34516kb
input:
1025
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #38:
score: 0
Accepted
time: 69ms
memory: 36268kb
input:
1026
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Test #39:
score: 0
Accepted
time: 79ms
memory: 36516kb
input:
1027
output:
Yes 4130784 63519 4065216 129087 3934080 258174 3936129 254076 3940227 245880 3946374 247929 3942276 252027 3680004 512250 3682053 508152 3686151 491760 3700494 493809 3696396 497907 3688200 504054 3690249 499956 3694347 467172 3725082 469221 3720984 473319 3704592 487662 3706641 483564 3710739 4753...
result:
ok 1
Extra Test:
score: 0
Extra Test Passed