# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94815 | quoriess | Rima (COCI17_rima) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pii;
#define dbg(x) cout<<#x<<" has a value of: "<<x<<"\n";
#define usize(x) (int)(x.size())
#define plist(x) for(int i=0;i<usize(x);i++)cout<<"eleman "<<i<<" = "<<x[i]<<"\n";
#define foreach(x) for(auto item:x)
#define fill(s,x) for(int i=0;i<x;i++)cin>>s[i];
#define in(veriler,a) (veriler.find(a)!=veriler.end())
#define btw(x,y,z) x>=y && x<=z
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
os << p.first << ", " << p.second;
return os;
}
int main(){
int n;
cin>>n;
vector<string> dizi;
for (int i = 0; i < n; i++)
{
string s;
cin>>s;
reverse(s.begin(),s.end());
dizi.push_back(s);
}
sort(dizi.begin(),dizi.end());
int mc=1;
int mx=1;
for (int i = 1; i < n; i++)
{
int k1=0;
while(k1<(int)min(dizi[i-1].size(),dizi[i].size()) && dizi[i-1][k1]==dizi[i][k]){
k1++;
}
int hm=max(dizi[i].size(),dizi[i-1].size());
if((k1==hm || k1==hm-1;){
mc++;
mx=max(mc,mx);
}
else{
mc=1;
}
}
cout<<mx<<"\n";
return 0;
}