Submission #51904

#TimeUsernameProblemLanguageResultExecution timeMemory
51904EntityITLozinke (COCI17_lozinke)C++14
100 / 100
386 ms4076 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 20005; string s[N]; map<string, int> cnt, rem; int ans, n; signed main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) cin >>s[i], cnt[ s[i] ] ++; for (int i = 1; i <= n; ++i) { for (int j = 0; j < s[i].size(); ++j) { string now = ""; for (int k = j; k < s[i].size(); ++k) { now += s[i][k]; if (cnt.count(now)) { ans += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0); rem[now] += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0); cnt[now] = (j == 0 && k + 1 == s[i].size() ? 1 : 0); } } } for (auto pa : rem) cnt[ pa.first ] += pa.second; rem.clear(); } cout << ans; return 0; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:17:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < s[i].size(); ++j) {
                         ~~^~~~~~~~~~~~~
lozinke.cpp:19:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int k = j; k < s[i].size(); ++k) {
                             ~~^~~~~~~~~~~~~
lozinke.cpp:22:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     ans += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                                                  ~~~~~~^~~~~~~~~~~~~~
lozinke.cpp:23:61: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     rem[now] += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                                                       ~~~~~~^~~~~~~~~~~~~~
lozinke.cpp:24:49: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     cnt[now] = (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                                           ~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...