QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#405733 | #5874. Mystery Square | cyb1010 | 0 | 18ms | 3860kb | C++14 | 2.6kb | 2024-05-06 12:59:45 | 2024-05-06 12:59:46 |
Judging History
answer
/**
* @author : cyb1010
* @date : 2024-05-06 10:23:57
* @file : grow.cpp
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef __uint128_t U;
U val, msk, UP;
int __, n, g[60], tot, N, A;
char s[130];
bool perf1(U dw) {
U l = sqrtl(dw), x;
while ((x = l * l) <= UP) {
if ((x ^ dw) & msk) {
l++;
continue;
}
for (int i = n - 1; ~i; i--) putchar((x >> i & 1) + '0');
while (A--) putchar('0');
putchar('\n');
return true;
}
return false;
}
bool perf2() {
U T = s[n - 1] - '0', x = 0, M = 0;
for (int i = 1; i < N; i++) {
T |= (s[n - i - 1] - '0') << i, M = M << 1 | 1;
if (((x * x) ^ T) & M) x += (U)1 << (i - 1);
}
x += (U)1 << N - 1;
x *= x;
if ((x ^ val) & msk) return false;
for (int i = n - 1; ~i; i--) putchar((x >> i & 1) + '0');
while (A--) putchar('0');
putchar('\n');
return true;
}
void work() {
scanf("%s", s), n = strlen(s), A = 0;
while (s[n - 1] == '0') n -= 2, A += 2;
while (n >= 1) {
s[n - 1] = '1';
N = (n + 1) / 2, tot = 0;
msk = val = UP = 0;
for (int i = 0; i < n; i++) {
msk <<= 1, val <<= 1, UP <<= 1;
if (s[i] == '?')
g[tot++] = i, UP |= 1;
else
msk |= 1, val |= (s[i] - '0'), UP |= (s[i] - '0');
}
if (!tot) {
for (int i = 0; i < n; i++) putchar(s[i]);
while (A--) putchar('0');
putchar('\n');
return;
}
int cnt = (tot + 1) / 2;
if (g[cnt] >= N) {
int M = 1 << cnt;
for (int i = 0; i < M; i++) {
U tmp = val;
for (int j = 0; j < cnt; j++) tmp |= (i >> j & 1) << g[j];
if (perf1(tmp)) return;
}
} else {
int M = 1 << cnt;
for (int i = 0; i < M; i++) {
for (int j = 0; j < cnt; j++)
s[g[tot - j - 1]] = '0' + (i >> j & 1);
if (perf2()) return;
}
}
n -= 2, A += 2;
}
assert(0);
}
int main() {
// fo("grow");
// work();
int _;
scanf("%d", &_);
for (int i = 1; i <= 5; i++) printf("Case #%d: ", i), work();
return 0 ^ __ ^ 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 18ms
memory: 3860kb
input:
25 1??? 1 10??110??00??1000?? 1??010?0110?1010?0?010?0111011?11100?100010?0??0??1 1??11????00??1?1?0?1??01??110110?11?00100110?00100?0?00 11?1?1???11111?11?1??11110000?00?????00??0?000?000?1 10??000000?0?00000?00000000??0?0000???00??????0000??? 101???11??11000?????1??1?1??10??0?0100011?0001?01011001...
output:
Case #1: 1001 Case #2: 1 Case #3: 1011110110000100001 Case #4: 111010001100101000001010111011011100110001000110001 Case #5: 1111111110011111101111011111011011110010011000000000000
result:
wrong answer 5th lines differ - expected: 'Case #5: 1101111110000101100101010111011001110010011000010000100', found: 'Case #5: 1111111110011111101111011111011011110010011000000000000'
Subtask #2:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
input:
25 1????????????????????111101010000011100110101111000001011111100110000011000101100000010010110100101000???????????????????? 10?11100?000111??11?01010110100??1?100111?001000000??0101?110?0111?011?11?1??00010111?010??100?100??10?010?001001110111110?1 1000100111100100110011010111100001111010?????????...