QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#459321 | #8830. Breaking Bad | ucup-team1447# | WA | 938ms | 3728kb | C++14 | 1.4kb | 2024-06-30 01:42:55 | 2024-06-30 01:42:55 |
Judging History
answer
#include <bits/stdc++.h>
std::mt19937 Rand(std::chrono ::system_clock::now().time_since_epoch().count());
int n, a[1024][1024], b[1024][1024], p[1024], q[1024], ans;
int tmp[32][32];
int plus(int A, int B)
{
int res = 0;
for (int i = 0; i != 5; ++i)
if (B >> i & 1)
res |= A << i;
return (res | res >> 5) & ((1 << 5) - 1);
}
int solve(int xl, int xr, int yl, int yr)
{
if (xr - xl == 1 && yr - yl == 1)
return 1 << b[xl][yl];
int xm = (xl + xr) >> 1, ym = (yl + yr) >> 1;
return tmp[solve(xl, xm, yl, ym)][ solve(xm, xr, ym, yr)] | tmp[solve(xm, xr, yl, ym)][ solve(xl, xm, ym, yr)];
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin >> n;
for(int i=0;i<32;++i)
for(int j=0;j<32;++j)
tmp[i][j]=plus(i,j);
for (int i = 0; i != n; ++i)
for (int j = 0; j != n; ++j)
std::cin >> a[i][j];
while (n & (n - 1))
++n;
std::iota(p, p + n, 0);
std::iota(q, q + n, 0);
do
{
std::shuffle(p, p + n, Rand);
std::shuffle(q, q + n, Rand);
for (int i = 0; i != n; ++i)
for (int j = 0; j != n; ++j)
b[p[i]][q[j]] = a[i][j];
ans |= solve(0, n, 0, n);
} while (clock() < 0.99 * CLOCKS_PER_SEC);
for (int i = 0; i != 5; ++i)
std::cout << (ans >> i & 1 ? "Y" : "N");
std::cout << std::endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 435ms
memory: 3600kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 471ms
memory: 3648kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 643ms
memory: 3612kb
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: 627ms
memory: 3608kb
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: 938ms
memory: 3728kb
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'