# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116809 | 2019-06-14T01:25:48 Z | minhcool | Lozinke (COCI17_lozinke) | C++17 | 193 ms | 2936 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 9 ms | 512 KB | Output is correct |
6 | Correct | 11 ms | 512 KB | Output is correct |
7 | Correct | 16 ms | 512 KB | Output is correct |
8 | Correct | 10 ms | 512 KB | Output is correct |
9 | Correct | 87 ms | 1304 KB | Output is correct |
10 | Correct | 54 ms | 1408 KB | Output is correct |
11 | Correct | 144 ms | 1852 KB | Output is correct |
12 | Correct | 100 ms | 1920 KB | Output is correct |
13 | Correct | 144 ms | 2424 KB | Output is correct |
14 | Correct | 193 ms | 2936 KB | Output is correct |
15 | Correct | 132 ms | 2552 KB | Output is correct |
16 | Correct | 21 ms | 512 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 143 ms | 2304 KB | Output is correct |
20 | Correct | 36 ms | 640 KB | Output is correct |