# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1078156 | 2024-08-27T13:25:32 Z | ntnq | Lozinke (COCI17_lozinke) | C++17 | 16 ms | 18776 KB |
#include <bits/stdc++.h> #define pii pair<int, int> #define fi first #define se second #define N 100005 #define quick ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; int n, a[N], ans; string s[N]; struct node { node* child[26]; int dem; }; node* u1 = new node(); void Add(string s) { node* u = u1; for (int i = 0 ; i < s.size();i++) { int k = s[i] - 'a'; if (u -> child[k] == NULL) u -> child[k] = new node(); u = u -> child[k]; u -> dem++; } } int getTrie(string s) { node* u = u1; for (int i = 0 ; i < s.size(); i++) { int k = s[i] - 'a'; u = u -> child[k]; if (i == s.size() - 1) return (u -> dem) - 1; } } int main() { quick; cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; Add(s[i]); } for (int i = 1; i <= n; i++) { ans += getTrie(s[i]); } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 3416 KB | Output isn't correct |
2 | Incorrect | 1 ms | 3420 KB | Output isn't correct |
3 | Incorrect | 2 ms | 3420 KB | Output isn't correct |
4 | Incorrect | 1 ms | 3676 KB | Output isn't correct |
5 | Incorrect | 2 ms | 3972 KB | Output isn't correct |
6 | Incorrect | 2 ms | 4108 KB | Output isn't correct |
7 | Incorrect | 3 ms | 4700 KB | Output isn't correct |
8 | Correct | 3 ms | 5212 KB | Output is correct |
9 | Incorrect | 6 ms | 6492 KB | Output isn't correct |
10 | Incorrect | 13 ms | 10772 KB | Output isn't correct |
11 | Incorrect | 7 ms | 8796 KB | Output isn't correct |
12 | Correct | 16 ms | 17648 KB | Output is correct |
13 | Incorrect | 8 ms | 7772 KB | Output isn't correct |
14 | Incorrect | 13 ms | 18008 KB | Output isn't correct |
15 | Incorrect | 13 ms | 18776 KB | Output isn't correct |
16 | Incorrect | 4 ms | 4188 KB | Output isn't correct |
17 | Correct | 4 ms | 3764 KB | Output is correct |
18 | Correct | 3 ms | 3676 KB | Output is correct |
19 | Incorrect | 10 ms | 12716 KB | Output isn't correct |
20 | Incorrect | 4 ms | 3928 KB | Output isn't correct |