Submission #75697686


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)

using namespace std;
const int N=2e6+10;
int n,m,tot,ch[N][2];
bool flg[N];
string s;
void dfs(int u,int d){
    if(d==m)return;
    int l=ch[u][0],r=ch[u][1];
    if(l)dfs(l,d+1);
    if(r)dfs(r,d+1);
    flg[u]=(l&&r&&flg[l]&&flg[r]);
    return;
}
signed main(){
	  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;rep(i,1,n){
        cin>>s;int u=0;
        rep(j,0,m-1){
            int c=(s[j]=='0');
            if(!ch[u][c])ch[u][c]=++tot;
            u=ch[u][c];
        }
        flg[u]=1;
    }
    dfs(0,0);if(flg[0])return cout<<"No\n",0;
    cout<<"Yes\n";int u=0;rep(i,1,m){
        if(u==-1){cout<<0;continue;}
        int l=ch[u][0],r=ch[u][1];
        if(!l||!flg[l])cout<<0,u=l?l:-1;
        else cout<<1,u=r?r:-1;
    }
	  cout<<"\n";
    return 0;
}

Submission Info

Submission Time
Task A - Similarity
User Fourier_WJY
Language C++23 (GCC 15.2.0)
Score 400
Code Size 961 Byte
Status AC
Exec Time 36 ms
Memory 19068 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 62
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-allbut-01.txt, 01-allbut-02.txt, 01-allbut-03.txt, 01-allbut-04.txt, 01-allbut-05.txt, 01-allbut-06.txt, 01-allbut-07.txt, 01-allbut-08.txt, 01-allbut-09.txt, 01-allbut-10.txt, 01-allbut-11.txt, 01-allbut-12.txt, 01-allbut-13.txt, 01-allbut-14.txt, 01-allbut-15.txt, 01-allbut-16.txt, 01-allbut-17.txt, 01-allbut-18.txt, 01-allbut-19.txt, 01-allbut-20.txt, 01-allbut-21.txt, 01-allbut-22.txt, 01-allbut-23.txt, 01-allbut-24.txt, 01-allbut-25.txt, 02-all-01.txt, 02-all-02.txt, 02-all-03.txt, 02-all-04.txt, 02-all-05.txt, 02-all-06.txt, 02-all-07.txt, 02-all-08.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 03-random-04.txt, 03-random-05.txt, 03-random-06.txt, 03-random-07.txt, 03-random-08.txt, 03-random-09.txt, 03-random-10.txt, 03-random-11.txt, 03-random-12.txt, 03-random-13.txt, 03-random-14.txt, 04-killer-01.txt, 04-killer-02.txt, 04-killer-03.txt, 04-killer-04.txt, 04-killer-05.txt, 04-killer-06.txt, 04-killer-07.txt, 04-killer-08.txt, 05-random2-01.txt, 05-random2-02.txt, 05-random2-03.txt, 05-random2-04.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 3544 KiB
00-sample-02.txt AC 1 ms 3580 KiB
00-sample-03.txt AC 1 ms 3500 KiB
01-allbut-01.txt AC 1 ms 3500 KiB
01-allbut-02.txt AC 1 ms 3504 KiB
01-allbut-03.txt AC 1 ms 3540 KiB
01-allbut-04.txt AC 1 ms 3376 KiB
01-allbut-05.txt AC 1 ms 3404 KiB
01-allbut-06.txt AC 1 ms 3396 KiB
01-allbut-07.txt AC 1 ms 3568 KiB
01-allbut-08.txt AC 1 ms 3572 KiB
01-allbut-09.txt AC 1 ms 3504 KiB
01-allbut-10.txt AC 1 ms 3464 KiB
01-allbut-11.txt AC 1 ms 3500 KiB
01-allbut-12.txt AC 1 ms 3544 KiB
01-allbut-13.txt AC 1 ms 3504 KiB
01-allbut-14.txt AC 1 ms 3580 KiB
01-allbut-15.txt AC 1 ms 3408 KiB
01-allbut-16.txt AC 1 ms 3524 KiB
01-allbut-17.txt AC 1 ms 3544 KiB
01-allbut-18.txt AC 1 ms 3728 KiB
01-allbut-19.txt AC 2 ms 3672 KiB
01-allbut-20.txt AC 2 ms 3724 KiB
01-allbut-21.txt AC 2 ms 3660 KiB
01-allbut-22.txt AC 2 ms 3888 KiB
01-allbut-23.txt AC 2 ms 3964 KiB
01-allbut-24.txt AC 2 ms 3928 KiB
01-allbut-25.txt AC 2 ms 3884 KiB
02-all-01.txt AC 1 ms 3540 KiB
02-all-02.txt AC 1 ms 3504 KiB
02-all-03.txt AC 1 ms 3416 KiB
02-all-04.txt AC 1 ms 3544 KiB
02-all-05.txt AC 1 ms 3708 KiB
02-all-06.txt AC 1 ms 3804 KiB
02-all-07.txt AC 2 ms 3628 KiB
02-all-08.txt AC 2 ms 3836 KiB
03-random-01.txt AC 1 ms 3676 KiB
03-random-02.txt AC 1 ms 3672 KiB
03-random-03.txt AC 1 ms 3700 KiB
03-random-04.txt AC 2 ms 3668 KiB
03-random-05.txt AC 2 ms 3848 KiB
03-random-06.txt AC 5 ms 4744 KiB
03-random-07.txt AC 9 ms 6900 KiB
03-random-08.txt AC 12 ms 8316 KiB
03-random-09.txt AC 20 ms 11864 KiB
03-random-10.txt AC 21 ms 12456 KiB
03-random-11.txt AC 22 ms 12584 KiB
03-random-12.txt AC 28 ms 15244 KiB
03-random-13.txt AC 35 ms 18172 KiB
03-random-14.txt AC 36 ms 18900 KiB
04-killer-01.txt AC 24 ms 19068 KiB
04-killer-02.txt AC 24 ms 18904 KiB
04-killer-03.txt AC 9 ms 3852 KiB
04-killer-04.txt AC 9 ms 3928 KiB
04-killer-05.txt AC 36 ms 18980 KiB
04-killer-06.txt AC 36 ms 18964 KiB
04-killer-07.txt AC 36 ms 18860 KiB
04-killer-08.txt AC 36 ms 18828 KiB
05-random2-01.txt AC 1 ms 3596 KiB
05-random2-02.txt AC 2 ms 3700 KiB
05-random2-03.txt AC 2 ms 3760 KiB
05-random2-04.txt AC 2 ms 3836 KiB