답안 #85398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85398 2018-11-19T18:58:26 Z MohamedAhmed0 Lozinke (COCI17_lozinke) C++14
100 / 100
556 ms 17772 KB
#include <bits/stdc++.h>

using namespace std;

bool cmp(string &s , string &s1)
{
    return s.size() < s1.size() ;
}

int main()
{
    int n ;
    cin>>n ;
    string arr[n] ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    sort(arr , arr + n , cmp) ;
    long long ans = 0ll ;
    map<string , int>mp ;
    for(int i = 0 ; i < n ; ++i)
    {
        string s = arr[i] ;
        map<string , int>mp2 ;
        ans += mp[s] ;
        for(int j = 0 ; j < s.size() ; ++j)
        {
            string s1 = "" ;
            for(int k = j ; k < s.size() ; ++k)
            {
                 s1 += s[k] ;
                 if(mp2[s1] != 1)
                    ans += mp[s1] * 1ll ;
                 mp2[s1] = 1 ;
            }
        }
        mp[s]++;
    }
    return cout<<ans , 0 ;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0 ; j < s.size() ; ++j)
                         ~~^~~~~~~~~~
lozinke.cpp:28:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int k = j ; k < s.size() ; ++k)
                             ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 3 ms 552 KB Output is correct
5 Correct 13 ms 936 KB Output is correct
6 Correct 22 ms 984 KB Output is correct
7 Correct 26 ms 1796 KB Output is correct
8 Correct 49 ms 2580 KB Output is correct
9 Correct 111 ms 2784 KB Output is correct
10 Correct 246 ms 7932 KB Output is correct
11 Correct 188 ms 7932 KB Output is correct
12 Correct 556 ms 17332 KB Output is correct
13 Correct 362 ms 17332 KB Output is correct
14 Correct 310 ms 17332 KB Output is correct
15 Correct 548 ms 17772 KB Output is correct
16 Correct 387 ms 17772 KB Output is correct
17 Correct 97 ms 17772 KB Output is correct
18 Correct 78 ms 17772 KB Output is correct
19 Correct 348 ms 17772 KB Output is correct
20 Correct 170 ms 17772 KB Output is correct