Submission #151899

# Submission time Handle Problem Language Result Execution time Memory
151899 2019-09-05T12:01:29 Z phillip Lozinke (COCI17_lozinke) C++14
30 / 100
584 ms 65540 KB
#include <bits/stdc++.h>

using namespace std;
bool cmp(string a,string b)
{
    if(a.size()<b.size())return true;
    return false;
}
int n;
string s[2009];
map<string,bool>m[2009];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n,cmp);
    //for(int i=0;i<n;i++)cout<<s[i]<<"\n";
    for(int i=0;i<n;i++)
    {
        for(int k=0;k<s[i].size();k++)
        {
            for(int j=0;j<s[i].size()-k;j++)
            {
                //cout<<s[i].substr(j,k+1)<<"\n";
                m[i][s[i].substr(j,k+1)]=1;
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(m[j][s[i]])ans++;
            if(s[i]==s[j])ans++;
        }
    }
    cout<<ans;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:20:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int k=0;k<s[i].size();k++)
                     ~^~~~~~~~~~~~
lozinke.cpp:22:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0;j<s[i].size()-k;j++)
                         ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 4 ms 888 KB Output is correct
4 Correct 26 ms 4856 KB Output is correct
5 Correct 177 ms 24824 KB Output is correct
6 Correct 584 ms 65076 KB Output is correct
7 Runtime error 465 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 509 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 5 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 4 ms 972 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 5 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 4 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)