QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#782614#4068. Distinctive CharacterharlemAC ✓48ms14796kbC++141.6kb2024-11-25 20:41:192024-11-25 20:41:21

Judging History

This is the latest submission verdict.

  • [2024-11-25 20:41:21]
  • Judged
  • Verdict: AC
  • Time: 48ms
  • Memory: 14796kb
  • [2024-11-25 20:41:19]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
typedef double db;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
template <typename Type>
using vec=vector<Type>;
template <typename Type>
using grheap=priority_queue<Type>;
template <typename Type>
using lrheap=priority_queue<Type,vector<Type>,greater<Type> >;
#define fir first
#define sec second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)

const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7/*998244353*/;

const int N=1e5+5,K=25;

int n,k;

bool vis[1<<21];
int dis[1<<21];

void print(int ans,int k){
    if(k>1)print(ans>>1,k-1);
    cout<<(ans&1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    char c;int t;
    queue<int> q;
    rep(i,1,n){
        t=0;
        rep(j,1,k){
            cin>>c;
            t=t<<1|(c-'0');
        }
        q.push(t);
        vis[t]=true;
    }
    int ans=0;
    while(!q.empty()){
        int now=q.front();q.pop();
        rep(i,0,k-1){
            int nxt=now^1<<i;
            if(vis[nxt])continue;
            dis[nxt]=dis[now]+1;
            vis[nxt]=true;
            q.push(nxt);
            if(dis[nxt]>dis[ans])ans=nxt;
        }
    }
    print(ans,k);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5644kb

input:

3 5
01001
11100
10111

output:

00010

result:

ok 

Test #2:

score: 0
Accepted
time: 1ms
memory: 5604kb

input:

1 4
0000

output:

1111

result:

ok 

Test #3:

score: 0
Accepted
time: 1ms
memory: 5548kb

input:

1 1
0

output:

1

result:

ok 

Test #4:

score: 0
Accepted
time: 1ms
memory: 5672kb

input:

1 2
01

output:

10

result:

ok 

Test #5:

score: 0
Accepted
time: 1ms
memory: 5604kb

input:

1 5
00100

output:

11011

result:

ok 

Test #6:

score: 0
Accepted
time: 28ms
memory: 11368kb

input:

1 20
00100000111011111010

output:

11011111000100000101

result:

ok 

Test #7:

score: 0
Accepted
time: 1ms
memory: 5640kb

input:

2 1
1
0

output:

0

result:

ok 

Test #8:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

2 2
10
01

output:

11

result:

ok 

Test #9:

score: 0
Accepted
time: 0ms
memory: 5600kb

input:

2 5
00010
00100

output:

11001

result:

ok 

Test #10:

score: 0
Accepted
time: 29ms
memory: 9580kb

input:

2 20
11110100100011011100
11110000000000110111

output:

00001111111111100011

result:

ok 

Test #11:

score: 0
Accepted
time: 1ms
memory: 5576kb

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: 0ms
memory: 5556kb

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: 1ms
memory: 5916kb

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: 32ms
memory: 11524kb

input:

100 20
00110011101000101001
11111100011011011101
00101010010111100001
01010010011000010110
11000010001101110111
00010001010000101101
10110010110010111101
11101111110011100101
11111010001001111111
10011011000111001101
11011000110101101000
01110010110011100111
01111001010000101110
11100010010110111111...

output:

11001001001001010000

result:

ok 

Test #15:

score: 0
Accepted
time: 1ms
memory: 5604kb

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: 1ms
memory: 5608kb

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: 0ms
memory: 5680kb

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: 32ms
memory: 13032kb

input:

1000 20
10010101010110101110
00001110001111100101
01100101111110000001
11011001011100011110
10010011111001010000
00010100100000100011
00100101000000101101
10110001001110011101
10010111111011011000
11011000010011011011
00100111100010101111
11010111110111111101
01000110010110110101
0010001110010001001...

output:

10010101010010111001

result:

ok 

Test #19:

score: 0
Accepted
time: 2ms
memory: 5808kb

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: 3ms
memory: 6040kb

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: 5ms
memory: 5984kb

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: 47ms
memory: 14796kb

input:

100000 20
00010100001101110001
00011111101100000111
11111101101111100110
00110100100100001010
01101010010100000001
00011100000101001101
01110010100110000001
11110011101010011100
11011100010011110011
01101010011110111101
10011111101011010111
00100000010001101100
10111010101001011001
10011000101000100...

output:

00010110001101110000

result:

ok 

Test #23:

score: 0
Accepted
time: 48ms
memory: 13884kb

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: 36ms
memory: 13588kb

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: 28ms
memory: 11872kb

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: 30ms
memory: 13216kb

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: 29ms
memory: 13816kb

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: 47ms
memory: 12288kb

input:

100000 20
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111110
00011111010010111...

output:

11100000101101000001

result:

ok