QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#869614 | #8830. Breaking Bad | JWRuixi | WA | 1ms | 3712kb | C++17 | 2.7kb | 2025-01-25 12:03:10 | 2025-01-25 12:03:11 |
Judging History
answer
#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define me(f, x) memset(f, x, sizeof(f))
#define mc(f, g) memcpy(f, g, sizeof(f))
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
using vi = vector<int>;
#endif
constexpr int N = 1e3 + 9;
int n, m, a[N][N];
int f[1 << 8];
int g[1 << 8];
int h[1 << 8][1 << 8];
IL int w (int s, int x) {
s <<= x;
return (s & 31) + (s >> 5);
}
int main () {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
L (i, 0, n - 1) {
L (j, 0, n - 1) {
cin >> a[i][j];
}
}
while (m < n && m < 8) {
L (i, m + 1, n - 1) {
L (j, m + 1, n - 1) {
if (a[m][m] + a[i][j] != a[m][j] + a[i][m]) {
goto end;
}
}
}
break;
end : m += 2;
}
cerr << m << '\n';
if (m >= 8) {
cout << "YYYYY\n";
return 0;
}
int off = 0;
L (i, m, n - 1) {
int d = a[i][m];
off += d;
L (j, 0, n - 1) {
a[i][j] -= d;
}
}
L (i, m, n - 1) {
int d = a[m][i];
off += d;
L (j, 0, n - 1) {
a[j][i] -= d;
}
}
L (i, 0, n - 1) {
L (j, 0, n - 1) {
a[i][j] = (a[i][j] % 5 + 5) % 5;
}
}
f[0] = g[0] = h[0][0] = 1;
L (j, m, n - 1) {
R (s, (1 << m) - 1, 0) {
L (i, 0, m - 1) {
if (~s >> i & 1) {
f[s | (1 << i)] |= w(f[s], a[i][j]);
}
}
}
}
L (i, m, n - 1) {
R (s, (1 << m) - 1, 0) {
L (j, 0, m - 1) {
if (~s >> j & 1) {
g[s | (1 << j)] |= w(g[s], a[i][j]);
}
}
}
}
L (s, 0, (1 << m) - 1) {
L (t, 0, (1 << m) - 1) {
L (i, 0, m - 1) if (~s >> i & 1) {
L (j, 0, m - 1) if (~t >> j & 1) {
h[s | (1 << i)][t | (1 << j)] |= w(h[s][t], a[i][j]);
}
}
}
}
string ans = "NNNNN";
L (s, 0, (1 << m) - 1) {
L (i, 0, 4) {
if (f[s] >> i & 1) {
L (t, 0, (1 << m) - 1) {
L (j, 0, 4) {
if (g[t] >> j & 1) {
L (k, 0, 4) {
if (h[(1 << m) - 1 - s][(1 << m) - 1 - t] >> k & 1) {
if ((off + i + j + k) % 5 == 4) {
cerr << s << ' ' << t << ' ' << i << ' ' << j << ' ' << k << '\n';
}
ans[(off + i + j + k) % 5] = 'Y';
}
}
}
}
}
}
}
}
cout << ans << '\n';
}
// I love WHQ!
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0
output:
YYYYN
result:
ok "YYYYN"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 0 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0
output:
YYYYN
result:
ok "YYYYN"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
10 1 4 2 0 0 2 0 1 3 3 0 3 1 4 4 1 4 0 2 2 1 4 2 0 0 2 0 1 0 3 0 3 1 4 4 1 4 0 2 2 4 2 0 3 3 0 3 4 1 1 2 0 3 1 1 3 1 2 4 4 4 2 0 3 3 0 3 4 1 1 2 0 3 1 1 3 1 2 4 4 1 4 2 0 0 2 0 1 3 3 3 1 4 2 2 4 2 3 0 0
output:
YYYYY
result:
wrong answer 1st words differ - expected: 'NYNNY', found: 'YYYYY'