답안 #730942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730942 2023-04-26T16:33:23 Z TheSahib Lozinke (COCI17_lozinke) C++14
100 / 100
235 ms 13644 KB
#include <bits/stdc++.h>

#define ll long long
#define pii pair<int, int>
const int oo = int(1e9) + 9;

using namespace std;

int n;
string arr[20006];
ll hashs[20006];
map<ll, int> mp;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        string s; cin >> s;
        arr[i] = s;
        set<ll> st;
        for (int j = 0; j < s.size(); ++j)
        {
            ll h = 0;
            for (int k = j; k < s.size(); k++)
            {
                h = (h * 26) + s[k] - 'a' + 1;
                st.insert(h);
                if(j == 0 && k == s.size() - 1){
                    hashs[i] = h;
                }
            }
        }
        for(auto& a:st){
            mp[a]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += mp[hashs[i]] - 1;
    }
    cout << ans << '\n';
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = 0; j < s.size(); ++j)
      |                         ~~^~~~~~~~~~
lozinke.cpp:24:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for (int k = j; k < s.size(); k++)
      |                             ~~^~~~~~~~~~
lozinke.cpp:28:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 if(j == 0 && k == s.size() - 1){
      |                              ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 940 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 7 ms 1192 KB Output is correct
7 Correct 10 ms 1720 KB Output is correct
8 Correct 17 ms 2388 KB Output is correct
9 Correct 37 ms 2460 KB Output is correct
10 Correct 94 ms 6440 KB Output is correct
11 Correct 61 ms 3812 KB Output is correct
12 Correct 214 ms 13644 KB Output is correct
13 Correct 108 ms 2556 KB Output is correct
14 Correct 161 ms 12252 KB Output is correct
15 Correct 235 ms 13516 KB Output is correct
16 Correct 98 ms 1300 KB Output is correct
17 Correct 23 ms 1212 KB Output is correct
18 Correct 19 ms 1248 KB Output is correct
19 Correct 137 ms 7328 KB Output is correct
20 Correct 49 ms 1364 KB Output is correct