QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579177 | #3319. Ranks | zlt | AC ✓ | 24ms | 5332kb | C++14 | 1.9kb | 2024-09-21 10:17:09 | 2024-09-21 10:17:12 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const int maxn = 1010;
int n, m, p[maxn];
char s[maxn][maxn];
bool vis[maxn], mk[maxn], can[maxn], f[maxn];
bitset<maxn> a[maxn], b[maxn], c[maxn], d[maxn], e[maxn];
void solve() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%s", s[i] + 1);
for (int j = 1; j <= m; ++j) {
if (s[i][j] == '1') {
a[i].set(j);
}
}
bitset<maxn> x = a[i], y;
y.reset();
y.set(i);
bool fl = 1;
for (int j = 1; j <= m; ++j) {
if (x.test(j)) {
if (b[j].none()) {
b[j] = x;
c[j] = y;
fl = 0;
break;
}
x ^= b[j];
y ^= c[j];
}
}
if (fl) {
for (int j = 1; j <= n; ++j) {
if (y.test(j)) {
mk[j] = 1;
}
}
}
}
int tot = 0;
for (int i = 1; i <= m; ++i) {
if (b[i].any()) {
b[++tot] = b[i];
c[tot] = c[i];
}
}
for (int i = 1; i <= tot; ++i) {
p[i] = b[i]._Find_first();
vis[p[i]] = 1;
for (int j = 1; j < i; ++j) {
if (b[j].test(p[i])) {
b[j] ^= b[i];
c[j] ^= c[i];
}
}
}
for (int i = 1; i <= tot; ++i) {
can[p[i]] = ((int)b[i].count() == 1);
}
for (int i = 1; i <= n; ++i) {
if (mk[i]) {
for (int j = 1; j <= m; ++j) {
if (vis[j]) {
putchar(can[j] ? '0' : '+');
} else {
putchar('+');
}
}
} else {
mems(f, 0);
for (int j = 1; j <= tot; ++j) {
if (c[j].test(i) && can[p[j]]) {
f[p[j]] = 1;
}
}
for (int j = 1; j <= m; ++j) {
putchar(f[j] ? '-' : '0');
}
}
putchar('\n');
}
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
31 31 1110011010000110001010001110010 1111101001010000001110110100110 1110011010000110001010001110010 1110100110111011111111010101101 0101110000101111011000110101111 1110011010000110001010001110010 0101111111100100011010101111110 1110100110111011111111010101101 1001100011100101111110001101001 010111...
output:
+++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ 0000000000000000000000000000000 +++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ 0000000000000000000000000000000 ++++++++++++...
result:
ok 31 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 4016kb
input:
26 26 10010011100011000110001111 00000000000000000000000000 11001111100101110110010010 11100111110101111010101100 11001111100101110110010010 11001111100101110110010010 11001111011010111000011010 01111110011110111010100100 11001111011010111000011010 11001111100101110110010010 110011110110101110000110...
output:
00000000000000000000000000 ++++++++++++++++++++++++++ ++++++++++++++++++++++++++ 00000000000000000000000000 ++++++++++++++++++++++++++ ++++++++++++++++++++++++++ ++++++++++++++++++++++++++ 00000000000000000000000000 ++++++++++++++++++++++++++ ++++++++++++++++++++++++++ ++++++++++++++++++++++++++ +++...
result:
ok 26 lines
Test #3:
score: 0
Accepted
time: 5ms
memory: 4460kb
input:
633 633 0110111110111110010011001111000111111111010111010101111001001111011011111111011000101111101011011011011010100100101101100010100000111110100101010000111011110110101010100111000011100010111111001111110101011101111101100110101110001001101111110001101110011101001000111001100011000111101101111000...
output:
+++++0++++++++++++++++++++++++++++++++++++++++0+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0++0+++0+++++++++++++++++0++++++++++++++000+++++0+++++0+++++++++++++++++++++++++++++++++++0+++0+++++++++++++++++++++++++++++++++++++++++++++++++++++++0+++++++++++++++++++++++++++++...
result:
ok 633 lines
Test #4:
score: 0
Accepted
time: 8ms
memory: 4788kb
input:
903 903 1110101101100001010010111101110100110111101011111100001000001110011101100101100000011111101111010101100111100000001011001100100001100110101010101011100001110100001000001111011100111111000001011000100100101001001011000001000011110100111011010011011001100000100001110101101100101100101111101100...
output:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
result:
ok 903 lines
Test #5:
score: 0
Accepted
time: 7ms
memory: 5308kb
input:
973 973 1101011110110110111001111100111010010111111110111001111110111001000101001110011111001011001111010010110110100100101011001111100011100010101010100111101100110101100000010001101100100001101011100110000010000011111010010111011011101000101000111011101100000010111001001010000010111010010001110100...
output:
+++++++++0++++++++++++++++0++++0+++++0+++++++0++++++++++++++++++++++++++0++00+++++++++++++++++++++++0+++++++++++++++++++++++0+++++++0+++++0+++++0+0++++++++++++++++++++++++++0+++++++0+++++0++++++++++++++++++++0+++++++++++++++++0+++++0+++++00++++++++++++++++0++0+++++++++++++++++++++++0+++++++++++0++++...
result:
ok 973 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
1 1 1
output:
-
result:
ok single line: '-'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 2 11 10
output:
0- --
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
3 3 011 101 111
output:
-0- 0-- ---
result:
ok 3 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
9 9 011111101 001110110 000001101 100101010 000011110 011001110 111010001 011011100 101111000
output:
000-0--00 0-00----0 --0------ 0--00--00 000--0--- 00--00--- --00-00-0 -0-0--00- 00-0----0
result:
ok 9 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
133 133 1111110110000100010110100010001010000111000000010011011111101010110111001001010101110100001100000011100011000101100111110000101110111 0011001111011101111001100010010100000000110100010011100111100010111001001111010101110100001110101100000101011111100111010001111001101 011110000101111100000011...
output:
----0000-0--00-000--000-0-0--0--0--0-0000-0--0--0-000--0000--00-00--00-0--0000000----00--0-0----0-0--00-------000-0------00-00000--0- 0-0-00-0-000---00-0--00--------000---0000--00-00---000----0--0-0-00000--0-0----0-0000-00------00---0000--0-----000000-----0--0-0-0-00 0-0000-0-00000-0-0--00--000-0--0...
result:
ok 133 lines
Test #11:
score: 0
Accepted
time: 8ms
memory: 4416kb
input:
581 581 0011111101010100110000100111011101011100011011111100111000000000100001101010111011000011100000110110011101010001100011010110000100101000000110010100100101100011110111110100010110110010000011110010001011001111101101101001010100011110110011000011100011100101101100011011111010011111100101100011...
output:
--00-0000--00-0000000---0-000-0000-00-0--0--0-00-0000--0-00--0000-0---0000----0000-000--0--0000---00-0-0---0-0--0-0000-0-0-----00-00-------0-00-0---0-0------0----000-00--0----0--000---0--000-0--00-0-0-00-000---0-0-0-0-000000---0-0-0-0---0-00-------0-000000---0-00--------0000-000----0000-0-000-0-----...
result:
ok 581 lines
Test #12:
score: 0
Accepted
time: 24ms
memory: 5332kb
input:
999 999 1100100000101010010100110110010000010110000001101110111110010101101111010011101110010001101001101000111010101011001000101111100110011110100101100100100111111011001001010101001000001110101001001101010001010000010010011011101011101001000011101011001011010111000100011110000000010010100000011110...
output:
0-00--00-----000---0-00-0-0-----000--00-0-00000-000---0---------0000--0----0--0000--00--0--0-00--0000----0000-0-0-0000000---0-0---------0---000---0-00-0---0-0--000----0----000-0---0-0--0--0-00000-00-000--0-00---0-0---00-0---0--0-00-0-00---00-00-000-00-000-00000-00000--000-----0-0-00--000---00-0-0000...
result:
ok 999 lines
Test #13:
score: 0
Accepted
time: 24ms
memory: 5044kb
input:
1000 1000 01000110001100011111111010010111100011010011000011001001001010000100001001100100101011101001101111101010001110110011000000001010111001011111001010110000010111111110100101011000001010001110100010010011110000000001010011001110000001001010010101101100001010110011011010011101100001011100011111...
output:
-0-00-00-0----0-0--0-00-00--000-0--0000-00--0--------0-00--0-000-00---0000-0--00-00--00--000-00---000000-0-----0-0----00--0-----00000---000-0--0-0--000-0-0-000-----00-000--00-0000-000--000-0-00--00------0-0-0-00-00-0-0-0---00--00-0-0000---0-000000----------00--0-0--0---0-00-----00-0-0--0-0-----0--0-...
result:
ok 1000 lines
Test #14:
score: 0
Accepted
time: 24ms
memory: 5056kb
input:
1000 1000 00010011010001010110000111110110010110010110001000000101111000010100111001010110010101001011110101000100001010101010001001010100101110100010101101101110000010001000010010001100011010111011111000111010101110101001010101100110000001011110010111111101101100101010110100010110100000111010000101...
output:
-0-000000----00000-0-0000--00000---0-0-0-0---0-000-0-000----0-0-00-0000--0--00-0-0--0--0----0--0000000-0--0---0-0-00---00--00-0-0-0000--0-00-0-0-0------00-0000--0-00000000-0---00-00----000-0---00--00---0-------0--000---0--0-00-0---0------0-00-000-0-00--00----0-0--0---0--000-0---0-0000-000-00-00-0---...
result:
ok 1000 lines
Test #15:
score: 0
Accepted
time: 17ms
memory: 5108kb
input:
1000 1000 00101001010100101000110001011111100001111001110100001100001101101101110110100011011100000011000100101011000101111101011101010100010000010111100110111101000100111010010011000000000111010111101110101000010011111010101101101100000011011001111101100101001101010111001110000101100000110110010100...
output:
-----00-000----00-0---0-00000-000----0-00-0-0----00----00--00-0-0--0-0----0000----0-----00-0-0000----000-0--00-0-000--0-00---0--0-0-000-000000-00-0--000-000-0--0-0-00---0--00000--000-000--0-0----0-0--0-000--0--0-00-0--000000---0---0-000---0-0000-0--0-0-0--00-------0--0000--00--000-0---0000--0----000...
result:
ok 1000 lines
Test #16:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10 9 011010011 000111101 011110100 110001100 011101011 101101101 010111001 110100010 100101101 011010011
output:
000000000 0-00--0-- -000--0-0 --0--0--- -00---00- ---0---0- 000-0---- 0-0000-0- ----0---- 000000000
result:
ok 10 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
10 8 00110010 01010011 01001101 00101001 00111010 01001111 10111001 10000101 00101001 01001101
output:
-00--00- ----000- 00000000 00000000 0-00--0- 00-00--- 00--0-0- -0--0-0- 00000000 00000000
result:
ok 10 lines
Test #18:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
7 10 0101100110 0100111111 1110110111 0100101111 0100110001 1111110001 1110100000
output:
000-00-00- 00000--00- 000-00000- 00000-000- 000-00000- 000000-00- 000-00-000
result:
ok 7 lines
Test #19:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
9 5 01111 01111 11000 00111 00001 10101 00001 00111 10101
output:
00000 00000 -0--0 00000 00000 00000 00000 00000 00000
result:
ok 9 lines
Test #20:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
5 10 1100101000 1010110110 0010010110 0101001001 0101011101
output:
0000000000 0000000000 0000000000 0000000000 0000000000
result:
ok 5 lines
Test #21:
score: 0
Accepted
time: 1ms
memory: 3920kb
input:
100 199 0110001111000101101011011010001101011000110101110110101100011100101111000001001111101000100110111011100110101011111111010001111000010001101101110110100000100001010100011000101011001110101110100100110 01110001101001000000011110000100101000000100110100000100001110001001010110110000001000001010...
output:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 100 lines
Test #22:
score: 0
Accepted
time: 20ms
memory: 5020kb
input:
999 1000 110011011101110101101110001110001001010010111000111010101111101000010101001110111000111101010100111001110111001000010111100111000100111010111100000111010000101011001010111011111000110101000000011110100100111100000000101100010110111100000010000101011010111101010001100011110111010100001010000...
output:
0--00--000000--0--0--0---00---0000--0-0--00-0--0--0-0--000-0--00---0-0-000-00----00---00-0000000000-0000----00--0---00-00--00-0-0---0----0-00-000----0-0----00--0--00-0--000-00000000000--0-0-000---00000---00-0-0-----0---0--0000----00-0--0---0-00--00---00--000-0000---00-0-0000--0-0-0-0--00--0-0-00-000...
result:
ok 999 lines
Test #23:
score: 0
Accepted
time: 16ms
memory: 5036kb
input:
1000 900 110000100110010011000101100001010100110000111101010110001100100010110110001111011001101101010011000000000100000100001010111000000101000101110110010101100010010100001111100001011100110001010010101100001110011001110010111101000010010101001111010110000011110000110101101001110000001010100111100...
output:
0--00--0000-0-0--0---000--0000--000--0--00-0-0-0-0000-00-000-000---00--00-0---0-0-0---00--00----0-0000-0-0---0-0-00-0--0-0-0--0-0000-00-00--00-00-00-0-0----0--0-000-0-0--0--000000------0---0-00000-0--0-000---0-0-0-0-00--0--000-0-000-0-0-0--0-00-000-00--00----0---00---00---0---0-00----00--00--------0...
result:
ok 1000 lines
Test #24:
score: 0
Accepted
time: 9ms
memory: 4456kb
input:
500 980 0111001100011100111101000000111101010110101110100101100100001001111110001000010101110010001111100000000111110100101101111000110011100010010100011100101111001110100010000010010011010101101111100001000101110000101111111011000001111101101110010110100011000001010011000111111110011010111101011010...
output:
000000000000000000000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 500 lines
Test #25:
score: 0
Accepted
time: 9ms
memory: 4780kb
input:
500 990 0010100100100100111001001001111110001011011100101100010001001110101101100011010001110101011001100001111100100101101100100010011111110011011001110010010010011100011100011000011111011101110011010000010001001001000000011000011001100101011111110011100101110101010001011110100010101001100101110010...
output:
00000000000000000000000-00000000000000000000-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 500 lines
Test #26:
score: 0
Accepted
time: 3ms
memory: 4544kb
input:
500 1000 100101110010110000111111001101001000101111101101101011101110000110111100101111111010010001011110100001100011100000111101001010100011011101111101001100101101110110110000110111011001111111101011100000101010001101101010110100001111110001000101100100110000111000001100000010010000100011000001011...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 500 lines
Test #27:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
1 1 0
output:
+
result:
ok single line: '+'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
2 3 000 000
output:
+++ +++
result:
ok 2 lines
Test #29:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1 1000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
result:
ok single line: '++++++++++++++++++++++++++++++...+++++++++++++++++++++++++++++++'