QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#462458 | #7302. Walk of Length 6 | alpha1022 | WA | 1ms | 5972kb | C++14 | 1.5kb | 2024-07-03 19:45:10 | 2024-07-03 19:45:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3;
int n;
int deg[N + 5];
bitset<N + 5> e[N + 5];
int c[N + 5][N + 5];
ll s[9];
bool solve() {
if (!~scanf("%d", &n)) return 0;
for (int i = 1; i <= n; ++i) e[i].reset(), deg[i] = 0;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) {
int x; scanf("%1d", &x);
if (x) e[i].set(j), ++deg[i];
}
fill_n(s, 9, 0);
for (int i = 1; i <= n; ++i) {
s[3] += deg[i] * (deg[i] - 1) / 2,
s[5] += deg[i] * (deg[i] - 1) * (deg[i] - 2) / 6;
}
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j) {
c[i][j] = c[j][i] = (e[i] & e[j]).count();
if (e[i].test(j))
s[0] += c[i][j], ++s[2],
s[6] += c[i][j] * (c[i][j] - 1) / 2,
s[4] += (deg[i] - 1) * (deg[j] - 1);
s[1] += c[i][j] * (c[i][j] - 1) / 2,
s[7] += (ll)c[i][j] * (c[i][j] - 1) / 2 * (deg[i] + deg[j] - 4);
}
s[4] -= s[0], s[7] -= s[6] * 2, s[0] /= 3, s[1] /= 2;
for (int i = 1; i <= n; ++i) {
ll t = 0;
for (int j = 1; j <= n; ++j)
if (e[i].test(j))
t += c[i][j];
t /= 2, s[8] += t * (t - 1) / 2;
}
s[8] -= s[6] * 2;
for (int i = 0; i < 9; ++i) printf("%d%c", s[i], " \n"[i == 8]);
printf("%lld\n", s[0] * 24 + s[1] * 48 + s[2] * 2 + s[3] * 12 + s[4] * 6 + s[5] * 12 + s[6] * 36 + s[7] * 12 + s[8] * 24);
return 1;
}
int main() {
while (solve());
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5972kb
input:
3 011 101 110 4 0101 1010 0101 1010 6 011111 101111 110111 111011 111101 111110
output:
1 0 3 3 0 0 0 0 0 66 0 1 4 4 4 0 0 0 0 128 20 45 15 60 180 60 90 360 90 14910
result:
wrong answer 1st numbers differ - expected: '66', found: '1'