답안 #798330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798330 2023-07-30T15:31:52 Z Hard_slipper Lozinke (COCI17_lozinke) C++14
100 / 100
151 ms 16064 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1; //cin >> T;
    int ot = T;
    while(T--)
    {
        int n; cin >> n;
        unordered_map<string, int> substr_freq;
        vector<string> strs;
        for(int i = 0; i < n; i++)
        {
            string s; cin >> s;
            strs.push_back(s);
            set<string> uniq;
            for(int j = 0; j < s.size(); j++)
            {
                string substring = "";
                for(int k = j; k < s.size(); k++)
                {
                    substring += s[k];
                    //cout << substring << '\n';
                    uniq.insert(substring);
                }
            }
            for(auto it : uniq)
            {
                substr_freq[it]++;
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            ans += substr_freq[strs[i]]-1;
        }
        cout << ans << '\n';
    }
}

Compilation message

lozinke.cpp: In function 'int32_t main()':
lozinke.cpp:22:30: 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]
   22 |             for(int j = 0; j < s.size(); j++)
      |                            ~~^~~~~~~~~~
lozinke.cpp:25:34: 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]
   25 |                 for(int k = j; k < s.size(); k++)
      |                                ~~^~~~~~~~~~
lozinke.cpp:11:9: warning: unused variable 'ot' [-Wunused-variable]
   11 |     int ot = T;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 596 KB Output is correct
6 Correct 7 ms 596 KB Output is correct
7 Correct 8 ms 1404 KB Output is correct
8 Correct 14 ms 2184 KB Output is correct
9 Correct 34 ms 2368 KB Output is correct
10 Correct 67 ms 7916 KB Output is correct
11 Correct 54 ms 4384 KB Output is correct
12 Correct 148 ms 16064 KB Output is correct
13 Correct 101 ms 2756 KB Output is correct
14 Correct 118 ms 15868 KB Output is correct
15 Correct 151 ms 15964 KB Output is correct
16 Correct 116 ms 1512 KB Output is correct
17 Correct 43 ms 1372 KB Output is correct
18 Correct 31 ms 1380 KB Output is correct
19 Correct 96 ms 8340 KB Output is correct
20 Correct 60 ms 1508 KB Output is correct