Submission #116817

#TimeUsernameProblemLanguageResultExecution timeMemory
116817manh9203Lozinke (COCI17_lozinke)C++17
90 / 100
1080 ms32504 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++){ string tmp=s[i].substr(j,len); if(check[tmp]==0){ ans=ans+cnt1[tmp]; check[tmp]=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++){ string tmp=s[i].substr(j,len); if(check[tmp]==0){ ans=ans+cnt2[tmp]; check[tmp]=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:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int len=1;len<=s[i].length();len++){
                 ~~~^~~~~~~~~~~~~~~
lozinke.cpp:30: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...