제출 #234392

#제출 시각아이디문제언어결과실행 시간메모리
234392VimmerLozinke (COCI17_lozinke)C++14
100 / 100
570 ms16504 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #define sz(x) ll(x.size()) #define base 1000000 #define M ll(1e9+7) #define N 100005 #define F first #define S second #define pb push_back #define in insert #define eb emplace_back #define ed "\n" using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef short int si; //typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; map <string, int> mp; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll ans =0 ; int n; cin >> n; string s[n]; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) { set <string> se; se.clear(); for (int kl = 0; kl < sz(s[i]); kl++) for (int kr = 0; kr < sz(s[i]) - kl; kr++) { string str = ""; for (int j = kl; j < sz(s[i]) - kr; j++) str += s[i][j]; if (se.find(str) == se.end()) {se.insert(str); mp[str]++;} } } for (int i = 0; i < n; i++) { mp[s[i]]--; ans += mp[s[i]]; mp[s[i]]++; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...