QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#543316 | #4161. 外星千足虫 | RainSky | 100 ✓ | 165ms | 4864kb | C++14 | 1.4kb | 2024-09-01 15:53:36 | 2024-09-01 15:53:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
#define fir first
#define sec second
#define ep emplace
#define eb emplace_back
#define lowbit(x) ((x) & (-(x)))
inline int read() {
int x = 0, f = 1; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
return x * f;
}
const int N = 2010;
int n, m;
bitset<N> a[N], b[N];
char s[N];
bool check(int m) {
for (int i = 1; i <= m; i ++ ) a[i] = b[i];
int r = 1, t = 1;
for (int c = 1; c <= n; c ++ , t = r) {
for (int i = t; i <= m; i ++ ) if (a[i][c]) t = i;
if (!a[t][c]) return false;
swap(a[r], a[t]);
for (int i = 1; i <= m; i ++ ) {
if (i == r || !a[i][c]) continue;
a[i] ^= a[r];
}
r ++ ;
}
return true;
}
int main() {
n = read(), m = read();
for (int i = 1; i <= m; i ++ ) {
scanf("%s", s + 1);
for (int j = 1; j <= n; j ++ ) b[i][j] = s[j] ^ '0';
scanf("%s", s + 1);
b[i][n + 1] = s[1] ^ '0';
}
int l = n, r = m, ans = -1;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid)) r = mid - 1, ans = mid;
else l = mid + 1;
}
if (ans == -1) return puts("Cannot Determine"), 0;
printf("%d\n", ans), check(ans);
for (int i = 1; i <= n; i ++ ) {
if (a[i][n + 1]) puts("?y7M#");
else puts("Earth");
}
return 0;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3776kb
input:
20 20 00101100011001010100 0 01000001111011011111 1 01011111001011110100 1 11011111001100000101 1 01110101100001101000 0 10011000001111011011 0 01100101110100111100 1 11011000011110000110 1 00100010100001010001 0 11011001011010101001 0 01011010000000000011 1 00110001000110101001 1 000000001000001110...
output:
20 ?y7M# ?y7M# Earth Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# Earth ?y7M# Earth
result:
ok all correct
Test #2:
score: 10
Accepted
time: 0ms
memory: 3708kb
input:
20 20 00110001000001011110 0 00111000001110011101 0 00010000011011111001 0 10001010011010101101 0 11011101010011010000 0 10011111001001010001 0 10110000101110101010 1 11101100000101011110 1 00010010010101100110 0 00111101010010100110 1 11111001111111011111 1 01010010001000000010 0 100111100111001110...
output:
Cannot Determine
result:
ok there are multiple solutions, so print Cannot Determine.
Test #3:
score: 10
Accepted
time: 4ms
memory: 4096kb
input:
400 400 1110111100111100111111101011100100111001100010100100110000101111100001111111101011100011110101100100000111001000100100001001000001110100111000011110000111101100001110000111101001011111001111100010100010110101101010001010111000001001000110111001111100011000101010000101110001111010111010011000...
output:
400 Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth ?y7M# Earth ?y7M# Earth ?y7M# ?y7M# Earth Earth Earth Earth Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth ?y7M# Earth Earth ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth Earth Earth Earth ?y7M# Earth Earth ?y7M# Ea...
result:
ok all correct
Test #4:
score: 10
Accepted
time: 6ms
memory: 4148kb
input:
500 500 1011011011100011001110110001011000001111010101101000101110000111100011000000110111001001110110001000001000111000111111010100001011010010001110000010011000101000111101001111100110111110010111111011011111110110000010100100101010011000100001011010110111001011100000110010110011110000001010001100...
output:
500 Earth ?y7M# Earth ?y7M# ?y7M# Earth ?y7M# Earth ?y7M# Earth Earth ?y7M# ?y7M# Earth ?y7M# Earth Earth Earth Earth Earth Earth Earth Earth Earth Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth Earth Earth Earth Earth Earth Earth Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# ?y...
result:
ok all correct
Test #5:
score: 10
Accepted
time: 11ms
memory: 4132kb
input:
300 500 1101101001001101011100100010000111000010111001011100011100111101110100011101110111111000100010001010000101101000110010001011100011000101000111101100010011101101100000000010101010011011011011001100101000100011000011001001010000001011110110010101001101000011000011001011010101110011101011101100...
output:
481 ?y7M# ?y7M# Earth Earth Earth ?y7M# ?y7M# Earth ?y7M# Earth Earth Earth ?y7M# Earth Earth Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth Earth ?y7M# Earth Earth Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth ?y7M# Earth Earth Earth ?y...
result:
ok all correct
Test #6:
score: 10
Accepted
time: 22ms
memory: 4292kb
input:
400 800 1101101001001010001110010110000101000000100001100111110001000010011110111110100100101010110110110101010101001011011110001011111100001001110111100100001110010011110000001100110010111101010000000010100100010100111011100110000011010100001000100001001001010011001011010000001010100100000000111000...
output:
769 Earth ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth Earth Earth ?y7M# Earth Earth Earth Earth ?y7M# Earth Earth Earth Earth Earth Earth Earth Earth Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# Earth ?y7M# Earth Earth Earth Earth Earth Earth Earth ?y7M# ?y7M# Earth Earth Earth ?y7M# ?y7M# Earth Earth Ea...
result:
ok all correct
Test #7:
score: 10
Accepted
time: 38ms
memory: 4264kb
input:
500 1000 011100001000001000001111111011100000101011110000011101110011011110100000001000011100110101101010111010101010010000000101110101001111111000101110110010111001011001000111111110101001101100100101100111000000011001111111001001110110011010101100010100010011000010111000111100010000111100111110000...
output:
997 ?y7M# Earth Earth Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth Earth Earth ?y7M# Earth ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# ?y7M# Earth ?y7M# ?y7M# Earth Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth Earth Ea...
result:
ok all correct
Test #8:
score: 10
Accepted
time: 91ms
memory: 4624kb
input:
800 1500 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
1455 Earth ?y7M# ?y7M# Earth Earth Earth Earth Earth Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth ?y7M# Earth ?y7M# Earth Earth ?y7M# Earth Earth E...
result:
ok all correct
Test #9:
score: 10
Accepted
time: 133ms
memory: 4768kb
input:
900 1800 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
1765 ?y7M# Earth Earth Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth ?y7M# Earth ?y7M# Earth ?y7M# Earth Earth ?y7M# Earth ?...
result:
ok all correct
Test #10:
score: 10
Accepted
time: 165ms
memory: 4864kb
input:
1000 2000 01111110000111111111110011011100000001111000011010000101110101001111101011100010101011001001110111001101000010110010000010000000110111101000110001110001001010110100001101000101101110011110000100100001010101110011000001001001111101111011000101101111110110000010011100100111111000101010101111...
output:
1982 Earth Earth ?y7M# ?y7M# ?y7M# ?y7M# Earth Earth Earth Earth Earth Earth ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth Earth ?y7M# Earth ?y7M# Earth Earth Earth ?y7M# Earth Earth Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# ?y7M# ?y7M# Earth ?y7M# Earth Earth ?y7M# ?y7M# ?y7M# Earth Earth Earth Earth ?y7M# ?y7M# ?...
result:
ok all correct