답안 #151900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151900 2019-09-05T12:03:35 Z phillip Lozinke (COCI17_lozinke) C++14
25 / 100
1000 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[20009];
map<string,bool>m[20009];
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++)
                         ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1912 KB Output is correct
2 Correct 4 ms 1912 KB Output is correct
3 Correct 5 ms 2296 KB Output is correct
4 Correct 27 ms 6264 KB Output is correct
5 Correct 178 ms 26232 KB Output is correct
6 Runtime error 439 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 438 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 512 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Execution timed out 1077 ms 25772 KB Time limit exceeded
10 Runtime error 430 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Execution timed out 1083 ms 26492 KB Time limit exceeded
12 Runtime error 323 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 319 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 526 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 276 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 309 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Execution timed out 1063 ms 17656 KB Time limit exceeded
18 Execution timed out 1084 ms 14500 KB Time limit exceeded
19 Runtime error 347 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Execution timed out 1070 ms 37728 KB Time limit exceeded