QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#780271 | #4068. Distinctive Character | highkj | AC ✓ | 158ms | 32924kb | C++11 | 1.5kb | 2024-11-25 09:26:21 | 2024-11-25 09:26:21 |
Judging History
answer
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define rep(i,x,y) for(register int i=x;i<=y;i++)
#define rep1(i,x,y) for(register int i=x;i>=y;--i)
#define int long long
#define fire signed
#define il inline
template<class T> il void print(T x) {
if(x<0) printf("-"),x=-x;
if (x > 9) print(x / 10);
putchar(x % 10 + '0');
}
template<class T> il void in(T &x) {
x = 0; char ch = getchar();
int f = 1;
while (ch < '0' || ch > '9') {if(ch=='-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
x *= f;
}
int T=1;
int n,k;
struct node{
int p,s;
};
queue<node>q;
const int N=1<<20;
int vis[N],ans[N];
void bfs() {
while(q.size()) {
node x=q.front();
q.pop();
vis[x.p]=1;
rep(j,0,k-1) {
node y=x;
y.p^=(1<<j);
if(vis[y.p]) continue;
// if(y.p==1) cout<<x.s+1<<endl;
ans[y.p]=x.s+1;
vis[y.p]=1;
q.push({y.p,x.s+1});
}
}
}
void solve() {
in(n),in(k);
memset(ans,0x3f,sizeof ans);
rep(i,1,n) {
int now=0;
rep(j,0,k-1) {
char c;
cin>>c;
if(c=='1') now|=(1<<j);
}
ans[now]=false;
vis[now]=1;
q.push({now,0});
}
bfs();
int res=0,id=0;
rep(i,0,(1<<k)-1) {
if(res<ans[i]) {
res=ans[i];
id=i;
}
}
rep(i,0,k-1) cout<<((id>>i)&1);
}
fire main() {
while(T--) {
solve();
}
return false;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 13424kb
input:
3 5 01001 11100 10111
output:
00010
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 11900kb
input:
1 4 0000
output:
1111
result:
ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 12064kb
input:
1 1 0
output:
1
result:
ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 12792kb
input:
1 2 01
output:
10
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 12712kb
input:
1 5 00100
output:
11011
result:
ok
Test #6:
score: 0
Accepted
time: 70ms
memory: 22784kb
input:
1 20 00100000111011111010
output:
11011111000100000101
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 11904kb
input:
2 1 1 0
output:
0
result:
ok
Test #8:
score: 0
Accepted
time: 2ms
memory: 12560kb
input:
2 2 10 01
output:
00
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 13036kb
input:
2 5 00010 00100
output:
11001
result:
ok
Test #10:
score: 0
Accepted
time: 72ms
memory: 23412kb
input:
2 20 11110100100011011100 11110000000000110111
output:
00001111011100000000
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 12320kb
input:
100 1 0 1 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 0 1 1 1 1 0 1 0
output:
0
result:
ok
Test #12:
score: 0
Accepted
time: 2ms
memory: 12732kb
input:
100 2 01 10 11 01 11 10 10 10 00 01 11 00 00 11 11 00 01 01 01 11 10 11 10 11 01 11 01 00 11 10 01 00 01 11 10 11 11 11 01 00 11 00 10 11 10 10 11 00 11 00 11 11 10 00 11 10 00 01 11 01 10 10 11 11 10 00 01 11 01 11 10 10 11 10 00 10 11 00 01 10 11 00 10 00 11 01 01 11 11 01 10 11 00 10 10 00 10 01 ...
output:
00
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 13132kb
input:
100 5 10010 00111 11100 01100 11010 01110 11111 11101 11000 01110 00011 00001 11110 10011 10001 11011 00010 11000 10000 01101 10101 00010 11100 11000 01000 01000 00110 10011 10100 01100 10011 01000 01110 00110 00011 10111 10001 10110 11000 00101 11010 01100 11011 11011 11010 10111 01010 10010 00111 ...
output:
01111
result:
ok
Test #14:
score: 0
Accepted
time: 57ms
memory: 27364kb
input:
100 20 00110011101000101001 11111100011011011101 00101010010111100001 01010010011000010110 11000010001101110111 00010001010000101101 10110010110010111101 11101111110011100101 11111010001001111111 10011011000111001101 11011000110101101000 01110010110011100111 01111001010000101110 11100010010110111111...
output:
10001001001001010000
result:
ok
Test #15:
score: 0
Accepted
time: 2ms
memory: 13296kb
input:
1000 1 0 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0...
output:
0
result:
ok
Test #16:
score: 0
Accepted
time: 2ms
memory: 13852kb
input:
1000 2 10 01 00 11 10 01 10 11 00 10 10 10 01 01 11 11 00 11 00 01 00 10 11 01 00 01 00 11 00 00 01 11 00 00 11 10 10 11 00 00 11 00 00 11 01 00 00 01 10 11 10 11 11 10 00 10 10 11 01 01 01 11 11 10 01 01 11 11 11 11 11 11 00 11 01 11 01 10 11 11 00 11 00 01 10 00 00 10 01 00 11 10 11 11 00 00 11 10...
output:
00
result:
ok
Test #17:
score: 0
Accepted
time: 3ms
memory: 13008kb
input:
1000 5 01101 00000 00110 01001 10100 01001 01110 00011 00111 01000 10000 01110 01100 00101 01101 00100 00001 01011 10000 01110 10111 10001 00001 11101 00011 11110 00100 11110 00010 11111 00101 00100 01001 11110 11000 01100 01110 11101 00111 00000 10100 11011 00001 00101 11010 00010 11010 00101 11101...
output:
00000
result:
ok
Test #18:
score: 0
Accepted
time: 69ms
memory: 29280kb
input:
1000 20 10010101010110101110 00001110001111100101 01100101111110000001 11011001011100011110 10010011111001010000 00010100100000100011 00100101000000101101 10110001001110011101 10010111111011011000 11011000010011011011 00100111100010101111 11010111110111111101 01000110010110110101 0010001110010001001...
output:
11000100000000000000
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 13576kb
input:
100000 1 1 1 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 0 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 1...
output:
0
result:
ok
Test #20:
score: 0
Accepted
time: 11ms
memory: 14468kb
input:
100000 2 00 00 01 01 10 00 01 10 00 00 00 00 10 11 00 10 01 10 10 11 00 10 10 00 10 01 10 01 00 11 01 10 01 11 10 11 00 01 11 11 01 10 00 01 00 11 00 10 01 01 00 11 01 01 11 10 11 01 01 00 11 11 01 10 01 00 01 10 01 10 10 10 11 11 10 00 00 01 01 00 01 01 01 11 01 10 11 01 10 00 10 01 00 01 11 00 00 ...
output:
00
result:
ok
Test #21:
score: 0
Accepted
time: 19ms
memory: 14984kb
input:
100000 5 10110 10000 00110 10111 11011 00101 11100 10111 11001 10101 00011 11001 00101 00010 10011 00110 00111 00010 10111 10000 11000 10000 00010 01111 11101 10010 11101 11010 10010 10111 10001 10010 10111 10101 11111 11110 00010 10010 10000 11101 11101 10110 10111 11110 10010 01000 01000 10111 001...
output:
00000
result:
ok
Test #22:
score: 0
Accepted
time: 148ms
memory: 32924kb
input:
100000 20 00010100001101110001 00011111101100000111 11111101101111100110 00110100100100001010 01101010010100000001 00011100000101001101 01110010100110000001 11110011101010011100 11011100010011110011 01101010011110111101 10011111101011010111 00100000010001101100 10111010101001011001 10011000101000100...
output:
00100000000000000000
result:
ok
Test #23:
score: 0
Accepted
time: 147ms
memory: 32868kb
input:
99973 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 111011010010111011...
output:
01110011111000010011
result:
ok
Test #24:
score: 0
Accepted
time: 79ms
memory: 31496kb
input:
9988 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 1110110100101110111...
output:
01110011111000010011
result:
ok
Test #25:
score: 0
Accepted
time: 66ms
memory: 29340kb
input:
981 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #26:
score: 0
Accepted
time: 66ms
memory: 28680kb
input:
467 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #27:
score: 0
Accepted
time: 58ms
memory: 27748kb
input:
172 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #28:
score: 0
Accepted
time: 158ms
memory: 22796kb
input:
100000 20 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111...
output:
11100000101101000001
result:
ok