QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621489 | #8651. Table Tennis | hhoppitree | 0 | 1ms | 3824kb | C++17 | 1.7kb | 2024-10-08 14:54:08 | 2024-10-08 14:54:09 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int deg[N], o[N];
bitset<N> G[N];
int cmp(int x, int y) {
return (deg[x] > deg[y]);
}
void output(int n) {
puts("Yes");
for (int i = 1; i <= n; ++i) {
iota(o + i + 1, o + n + 1, i + 1);
sort(o + i + 1, o + n + 1, cmp);
for (int j = i + 1; j <= n; ++j) {
G[o[j]][i] = (j <= n - deg[i]);
deg[i] -= G[o[j]][i];
assert(!deg[i]);
deg[o[j]] -= G[o[j]][i];
}
}
for (int i = 2; i <= n; ++i) {
for (int j = 1; j < i; ++j) putchar(G[i][j] + '0');
puts("");
}
}
signed main() {
int T; scanf("%d", &T);
while (T--) {
int n;
long long m;
scanf("%d%lld", &n, &m);
int fl = 0;
for (int tn = 1; tn <= n; ++tn) {
int S = 0;
for (int i = 1; i <= tn; ++i) {
deg[i] = (tn - 1) / 2 + ((tn & 1) ? 0 : (i > tn / 2));
S += 1ll * deg[i] * (deg[i] - 1) / 2;
}
if (S > tn * (tn - 1ll) * (tn - 2) / 6 - m) continue;
int ts = (tn * (tn - 1ll) * (tn - 2) / 6 - m) - S;
while (ts) {
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n && ts; ++j) {
if (deg[i] == deg[j]) {
--deg[i], ++deg[j], --ts;
}
}
}
}
for (int i = tn + 1; i <= n; ++i) {
deg[i] = i - 1;
}
fl = 1;
output(n);
break;
}
if (!fl) puts("No");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
97 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 59 0 60 0 61 0 62 0 63 0...
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #58:
score: 4
Accepted
time: 1ms
memory: 3756kb
input:
1 4 4
output:
No
result:
ok good job! (1 test case)
Test #59:
score: 4
Accepted
time: 0ms
memory: 3568kb
input:
1 5 10
output:
No
result:
ok good job! (1 test case)
Test #60:
score: 4
Accepted
time: 1ms
memory: 3576kb
input:
1 6 20
output:
No
result:
ok good job! (1 test case)
Test #61:
score: 4
Accepted
time: 1ms
memory: 3824kb
input:
1 7 35
output:
No
result:
ok good job! (1 test case)
Test #62:
score: 4
Accepted
time: 1ms
memory: 3764kb
input:
1 5 10
output:
No
result:
ok good job! (1 test case)
Test #63:
score: 4
Accepted
time: 1ms
memory: 3816kb
input:
1 6 19
output:
No
result:
ok good job! (1 test case)
Test #64:
score: 4
Accepted
time: 0ms
memory: 3612kb
input:
1 6 20
output:
No
result:
ok good job! (1 test case)
Test #65:
score: 4
Accepted
time: 1ms
memory: 3772kb
input:
1 7 33
output:
No
result:
ok good job! (1 test case)
Test #66:
score: 4
Accepted
time: 1ms
memory: 3824kb
input:
1 7 33
output:
No
result:
ok good job! (1 test case)
Test #67:
score: 4
Accepted
time: 1ms
memory: 3812kb
input:
1 4 3
output:
No
result:
ok good job! (1 test case)
Test #68:
score: 4
Accepted
time: 1ms
memory: 3568kb
input:
1 5 8
output:
No
result:
ok good job! (1 test case)
Test #69:
score: 4
Accepted
time: 1ms
memory: 3752kb
input:
1 6 17
output:
No
result:
ok good job! (1 test case)
Test #70:
score: 4
Accepted
time: 1ms
memory: 3712kb
input:
1 7 30
output:
No
result:
ok good job! (1 test case)
Test #71:
score: 0
Runtime Error
input:
2 3 0 3 1
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%