Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool check(char a[],char b[]){
- int n=strlen(a);
- int cnt=0;
- for(int i=0;i<n;i++){
- if(a[i]!=b[i]) cnt++;
- if(cnt>2) return true;
- }
- return false;
- }
- int main(){
- int n,m;
- scanf("%d%d",&n,&m);
- char a[n+2],b[n+2];
- bool chk=0;
- for(int i=0;i<m;i++){
- if(i!=0&&!chk) strcpy(b,a);
- scanf("%s",a);
- if(i==0||chk) continue;
- if(check(a,b)){
- chk=1;
- }
- }
- if(chk==1) cout << b;
- else
- cout << a;
- }
Advertisement
Add Comment
Please, Sign In to add comment