Submission #116814

#TimeUsernameProblemLanguageResultExecution timeMemory
116814manh9203Lozinke (COCI17_lozinke)C++17
90 / 100
1069 ms32632 KiB
#include<bits/stdc++.h> using namespace std; bool cmp(string a,string b){ return a.length() < b.length(); } long long n,ans; string s[20005]; map<string,int> cnt1,cnt2; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>s[i]; sort(s+1,s+1+n,cmp); for(int i=1;i<=n;i++){ map<string,bool> check; for(int len=1;len<=s[i].length();len++){ for(int j=0;j+len-1<s[i].length();j++){ if(check[s[i].substr(j,len)]==0){ ans=ans+cnt1[s[i].substr(j,len)]; check[s[i].substr(j,len)]=1; } } } cnt1[s[i]]++; } for(int i=n;i>=1;i--){ map<string,bool> check; for(int len=1;len<=s[i].length();len++){ for(int j=0;j+len-1<s[i].length();j++){ if(check[s[i].substr(j,len)]==0){ ans=ans+cnt2[s[i].substr(j,len)]; check[s[i].substr(j,len)]=1; } } } cnt2[s[i]]++; } cout<<ans; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int len=1;len<=s[i].length();len++){
                 ~~~^~~~~~~~~~~~~~~
lozinke.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j+len-1<s[i].length();j++){
                ~~~~~~~^~~~~~~~~~~~~~
lozinke.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int len=1;len<=s[i].length();len++){
                 ~~~^~~~~~~~~~~~~~~
lozinke.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j+len-1<s[i].length();j++){
                ~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...