Submission #44289

#TimeUsernameProblemLanguageResultExecution timeMemory
44289JustInCaseLozinke (COCI17_lozinke)C++17
100 / 100
641 ms17604 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int32_t MAX_N = 20005; string passwords[MAX_N]; map< string, bool > currSubstrings; map< string, int32_t > substringsCnt; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int32_t n; cin >> n; for(int32_t i = 1; i <= n; i++) { cin >> passwords[i]; } for(int32_t i = 1; i <= n; i++) { currSubstrings.clear(); for(int32_t l = 0; l < (int32_t) passwords[i].size(); l++) { string curr = ""; for(int32_t r = l; r < (int32_t) passwords[i].size(); r++) { curr += passwords[i][r]; if(currSubstrings.count(curr) == 0) { currSubstrings[curr] = true; substringsCnt[curr]++; } } } } int32_t ans = 0; for(int32_t i = 1; i <= n; i++) { ans += substringsCnt[passwords[i]] - 1; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...