Submission #472999

# Submission time Handle Problem Language Result Execution time Memory
472999 2021-09-14T17:51:10 Z MamdouhN Lozinke (COCI17_lozinke) C++17
25 / 100
1000 ms 65540 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

int n,ans;
string password[20005];
//map<string,bool>idk;
map<string,map<string,bool>>idk;

void get_subs(string s)
{
    string x;
    for(int i=0;i<s.size();i++)
    {
        x+=s[i];
        idk[s][x]=1;
        string y;
        int j = i;
        while(j>=0&&y.size()<s.size())
        {
            y=s[j]+y;
            idk[s][y]=1;
            j--;
        }
    }
}

void check(string a,string b)
{
    if(idk[a][b])ans++;
}

main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>password[i];
    for(int i=0;i<n;i++)
    {
        get_subs(password[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j==i)continue;
            if(password[j].size()>password[i].size())continue;
            //cout<<password[i]<<" "<<password[j]<<endl;
            check(password[i],password[j]);
            //cout<<ans<<endl;
        }
    }
    cout<<ans<<endl;
}

Compilation message

lozinke.cpp: In function 'void get_subs(std::string)':
lozinke.cpp:14:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
lozinke.cpp: At global scope:
lozinke.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 908 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 3 ms 1228 KB Output is correct
4 Correct 48 ms 4260 KB Output is correct
5 Correct 207 ms 27564 KB Output is correct
6 Runtime error 453 ms 65540 KB Execution killed with signal 9
7 Runtime error 468 ms 65540 KB Execution killed with signal 9
8 Runtime error 563 ms 65540 KB Execution killed with signal 9
9 Runtime error 746 ms 65540 KB Execution killed with signal 9
10 Runtime error 518 ms 65540 KB Execution killed with signal 9
11 Runtime error 642 ms 65540 KB Execution killed with signal 9
12 Runtime error 569 ms 65540 KB Execution killed with signal 9
13 Runtime error 607 ms 65540 KB Execution killed with signal 9
14 Runtime error 452 ms 65540 KB Execution killed with signal 9
15 Runtime error 537 ms 65540 KB Execution killed with signal 9
16 Execution timed out 1100 ms 19740 KB Time limit exceeded
17 Execution timed out 1095 ms 844 KB Time limit exceeded
18 Execution timed out 1098 ms 844 KB Time limit exceeded
19 Runtime error 589 ms 65540 KB Execution killed with signal 9
20 Execution timed out 1081 ms 15620 KB Time limit exceeded