Submission #116819

#TimeUsernameProblemLanguageResultExecution timeMemory
116819nhimnam120Lozinke (COCI17_lozinke)C++14
45 / 100
1083 ms1784 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; vector<pair<long long, string> > inp; signed main(){ long long n; cin >> n; for(int i=0;i<n;i++){ string s; cin >> s; inp.push_back({s.size(),s}); } long long ans=0; sort(inp.begin(),inp.end()); for(int i=0;i<n;i++){ for(int j=0;j<i;j++){ if(inp[i].fi==inp[j].fi){ if(inp[i].se==inp[j].se){ //cout << inp[i].se<< " " << inp[j].se<<endl; ans+=2; } } else{ string a=inp[i].se; string b=inp[j].se; //cout << a << " " << b<< " " <<inp[i].fi-inp[j].fi+1<< " "<< ans<<" "; for(int k=0;k<inp[i].fi-inp[j].fi+1;k++){ if(a[k]==b[0]){ long long test=0; for(int l=0;l<inp[j].fi;l++){ if(a[k+l]!=b[l]){ test=1; break; } } if(test==0){ ans++; break; } } } //cout << ans <<endl; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...