답안 #472996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472996 2021-09-14T17:49:28 Z MamdouhN Lozinke (COCI17_lozinke) C++14
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[200002];
//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()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 4 ms 6604 KB Output is correct
3 Correct 6 ms 6860 KB Output is correct
4 Correct 41 ms 9872 KB Output is correct
5 Correct 213 ms 33220 KB Output is correct
6 Runtime error 466 ms 65540 KB Execution killed with signal 9
7 Runtime error 442 ms 65540 KB Execution killed with signal 9
8 Runtime error 513 ms 65540 KB Execution killed with signal 9
9 Runtime error 618 ms 65540 KB Execution killed with signal 9
10 Runtime error 477 ms 65540 KB Execution killed with signal 9
11 Runtime error 603 ms 65540 KB Execution killed with signal 9
12 Runtime error 503 ms 65540 KB Execution killed with signal 9
13 Runtime error 560 ms 65540 KB Execution killed with signal 9
14 Runtime error 428 ms 65540 KB Execution killed with signal 9
15 Runtime error 500 ms 65540 KB Execution killed with signal 9
16 Execution timed out 1089 ms 25192 KB Time limit exceeded
17 Execution timed out 1087 ms 6732 KB Time limit exceeded
18 Execution timed out 1059 ms 6604 KB Time limit exceeded
19 Runtime error 553 ms 65540 KB Execution killed with signal 9
20 Execution timed out 1090 ms 21160 KB Time limit exceeded