제출 #798314

#제출 시각아이디문제언어결과실행 시간메모리
798314Hard_slipperLozinke (COCI17_lozinke)C++17
25 / 100
148 ms16212 KiB
#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';
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...