QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#459319 | #8830. Breaking Bad | ucup-team1447# | WA | 860ms | 5804kb | C++14 | 1.4kb | 2024-06-30 01:41:10 | 2024-06-30 01:41:11 |
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.9 * CLOCKS_PER_SEC);
for (int i = 0; i != 5; ++i)
std::cout << (ans >> i & 1 ? "Y" : "N");
std::cout << std::endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 460ms
memory: 5752kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 424ms
memory: 5796kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 612ms
memory: 5744kb
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: 613ms
memory: 5760kb
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: 860ms
memory: 5804kb
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'