답안 #116820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116820 2019-06-14T01:48:23 Z souhhcong Lozinke (COCI17_lozinke) C++14
100 / 100
308 ms 15580 KB
#include <iostream>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;

const int N = 2e4+5;
int n, cnt = 0;
string s[N];
unordered_map<string,int> mp;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        mp[s[i]]++;
    }
//    cout << s[0].substr(0,1) << endl;
    for (int i = 0; i < n; i++)
    {
        unordered_set<string> Set;
        for (int j = 0; j < s[i].size(); j++)
        {
            for (int k = j+1; k <= s[i].size(); k++)
            {
                string tmp = s[i].substr(j,k-j);
                Set.insert(tmp);
            }
        }
        for (auto x: Set)
        {
            cnt += mp[x];
        }
    }

    cout << cnt-n;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < s[i].size(); j++)
                         ~~^~~~~~~~~~~~~
lozinke.cpp:29:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int k = j+1; k <= s[i].size(); k++)
                               ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 8 ms 1280 KB Output is correct
6 Correct 11 ms 1280 KB Output is correct
7 Correct 15 ms 2176 KB Output is correct
8 Correct 23 ms 2816 KB Output is correct
9 Correct 56 ms 2680 KB Output is correct
10 Correct 142 ms 7376 KB Output is correct
11 Correct 99 ms 4268 KB Output is correct
12 Correct 308 ms 15580 KB Output is correct
13 Correct 152 ms 2740 KB Output is correct
14 Correct 211 ms 14008 KB Output is correct
15 Correct 308 ms 15160 KB Output is correct
16 Correct 154 ms 1272 KB Output is correct
17 Correct 64 ms 896 KB Output is correct
18 Correct 49 ms 896 KB Output is correct
19 Correct 190 ms 8068 KB Output is correct
20 Correct 148 ms 1272 KB Output is correct