Submission #798314

# Submission time Handle Problem Language Result Execution time Memory
798314 2023-07-30T15:13:31 Z Hard_slipper Lozinke (COCI17_lozinke) C++17
25 / 100
148 ms 16212 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);
            for(int j = 0; j < s.size(); j++)
            {
                set<string> uniq;
                for(int k = j; k < s.size(); k++)
                {
                    string substring = s.substr(j, (k-j)+1);
                    //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:21: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]
   21 |             for(int j = 0; j < s.size(); j++)
      |                            ~~^~~~~~~~~~
lozinke.cpp:24: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]
   24 |                 for(int k = j; k < s.size(); k++)
      |                                ~~^~~~~~~~~~
lozinke.cpp:11:9: warning: unused variable 'ot' [-Wunused-variable]
   11 |     int ot = T;
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Incorrect 3 ms 708 KB Output isn't correct
6 Incorrect 5 ms 596 KB Output isn't correct
7 Incorrect 7 ms 1364 KB Output isn't correct
8 Correct 11 ms 2224 KB Output is correct
9 Incorrect 26 ms 2464 KB Output isn't correct
10 Correct 51 ms 8040 KB Output is correct
11 Incorrect 42 ms 4480 KB Output isn't correct
12 Correct 148 ms 16212 KB Output is correct
13 Incorrect 85 ms 2992 KB Output isn't correct
14 Incorrect 105 ms 15896 KB Output isn't correct
15 Correct 114 ms 16088 KB Output is correct
16 Incorrect 95 ms 1764 KB Output isn't correct
17 Correct 102 ms 1612 KB Output is correct
18 Incorrect 73 ms 1544 KB Output isn't correct
19 Incorrect 87 ms 8488 KB Output isn't correct
20 Incorrect 51 ms 1640 KB Output isn't correct