# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116865 | 2019-06-14T02:59:35 Z | nhimnam120 | Lozinke (COCI17_lozinke) | C++14 | 424 ms | 17344 KB |
#include<bits/stdc++.h> #define fi first #define se second using namespace std; map<string, long long> cnt; vector<pair<long long,string> > inpp; set<string> inp; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; for(int i=0;i<n;i++){ string a; cin >> a; cnt[a]++; inp.insert(a); } long long ans=0; for(auto x: inp){ inpp.push_back({x.size(),x}); } sort(inpp.begin(),inpp.end()); for(int i=0;i<inpp.size();i++){ long long pos=0; string a=inpp[i].se; ans=ans+(cnt[a]*(cnt[a]-1)); string c; set<string> check; for(int j=1;j<inpp[i].fi;j++){ for(int k=0;k<inpp[i].fi-j+1;k++){ c=a.substr(k,j); check.insert(c); } } for(auto s:check){ ans=ans+cnt[a]*cnt[s]; } } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 512 KB | Output is correct |
5 | Correct | 13 ms | 896 KB | Output is correct |
6 | Correct | 20 ms | 768 KB | Output is correct |
7 | Correct | 27 ms | 1656 KB | Output is correct |
8 | Correct | 36 ms | 2424 KB | Output is correct |
9 | Correct | 110 ms | 2744 KB | Output is correct |
10 | Correct | 186 ms | 8088 KB | Output is correct |
11 | Correct | 191 ms | 4956 KB | Output is correct |
12 | Correct | 394 ms | 17260 KB | Output is correct |
13 | Correct | 275 ms | 3668 KB | Output is correct |
14 | Correct | 419 ms | 16240 KB | Output is correct |
15 | Correct | 424 ms | 17344 KB | Output is correct |
16 | Correct | 35 ms | 768 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 279 ms | 9328 KB | Output is correct |
20 | Correct | 34 ms | 768 KB | Output is correct |