Created
October 22, 2016 16:33
-
-
Save behitek/ffa3d4dd682ed7234d51fc75d3632729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
bool isSmaller(string a,string b){ | |
if(a.length() < b.length()) return 1; | |
if(a.length() > b.length()) return 0; | |
for(int i = 0;i < a.length();i++){ | |
if(a[i] < b[i]){ | |
return 1; | |
} | |
} | |
return 0; | |
} | |
void solve() { | |
int n,l; | |
string s,comp = "0",ans,temp; | |
cin>>n; | |
while(n--){ | |
cin>>s; | |
l = s.length(); | |
if(l == 1) temp = s; | |
else if(l&1){ | |
/*Neu l la so le*/ | |
temp = s[l/2]; | |
}else{ | |
temp = s.substr(l/2-1,2); | |
} | |
cout<<comp<<" "<<temp<<" "<<(temp > comp)<<endl; | |
if(isSmaller(comp,temp)){ | |
comp = temp; | |
ans = s; | |
} | |
} | |
cout<<ans<<endl; | |
} | |
int main(){ | |
#ifdef HieuNguyen | |
freopen("input.txt","r",stdin); | |
//freopen("output.txt","w",stdout); | |
#endif | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
solve(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment