QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#869610 | #8830. Breaking Bad | JWRuixi | WA | 0ms | 3584kb | C++17 | 2.5kb | 2025-01-25 11:58:45 | 2025-01-25 11:58:47 |
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;
}
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 (s, 0, (1 << m) - 1) {
L (i, 0, m - 1) {
if (~s >> i & 1) {
L (j, m, n - 1) {
f[s | (1 << i)] |= w(f[s], a[i][j]);
}
}
}
}
L (s, 0, (1 << m) - 1) {
L (j, 0, m - 1) {
if (~s >> j & 1) {
L (i, m, n - 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) {
ans[(off + i + j + k) % 5] = 'Y';
}
}
}
}
}
}
}
}
cout << ans << '\n';
}
// I love WHQ!
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
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: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
4 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0
output:
YYYYY
result:
wrong answer 1st words differ - expected: 'YYYYN', found: 'YYYYY'