Submission #116809

#TimeUsernameProblemLanguageResultExecution timeMemory
116809minhcoolLozinke (COCI17_lozinke)C++17
100 / 100
193 ms2936 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n, ans; map<string, int> mp; set<string> se2; set<string> se; signed main(){ ios_base::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++){ string x; cin >> x; mp[x]++; se.insert(x); } for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++){ int cnt = 0; string x = it->first; se2.clear(); for(int i = 0; i < x.length(); i++){ for(int j = 1; j + i <= x.length(); j++){ string tmp = x.substr(i, j); if(se.find(tmp) != se.end() && se2.find(tmp) == se2.end()){ //cout << i << " " << j << " " << x << " " << tmp << "\n"; cnt += mp[tmp]; se2.insert(tmp); } } } cnt--; ans += cnt * it->second; //cout << x << " " << cnt << endl; } cout << ans; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:23:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < x.length(); i++){
                        ~~^~~~~~~~~~~~
lozinke.cpp:24:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 1; j + i <= x.length(); j++){
                            ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...