Submission #234430

#TimeUsernameProblemLanguageResultExecution timeMemory
234430NONAMELozinke (COCI17_lozinke)C++17
100 / 100
469 ms19264 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define sz(x) int(x.size()) #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #define N 100500 #define oo ll(1e16) #define ft first #define sd second #define mp make_pair #define pb push_back #define ppb pop_back #define el '\n' #define elf endl #define base ll(1e9 + 7) using namespace std; typedef long long ll; typedef long double ld; int n, ans; string s[N]; map <string, int> ma; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; int len = sz(s[i]); set <string> se; se.clear(); for (int l = 0; l < len; l++) { string t; for (int r = l; r < len; r++) { t += s[i][r]; se.insert(t); } } for (string t : se) ma[t]++; } for (int i = 0; i < n; i++) ans += ma[s[i]]; cout << ans - n; }
#Verdict Execution timeMemoryGrader output
Fetching results...