# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115193 | 2019-06-06T00:15:40 Z | CaroLinda | Type Printer (IOI08_printer) | C++14 | 136 ms | 49016 KB |
#include <bits/stdc++.h> #define pii pair<int,int> #define lp(i,a,b) for(int i=a;i<b;i++) #define ll long long #define ff first #define ss second #define pb push_back const int MAXN = 25002; const int ALF= 26; using namespace std ; int n ; int trie[MAXN*20][ALF] , cnt ; int separa = 1 ; vector<char> ans ; bool marc[MAXN*20] ; void add( string str ) { int t = str.size() ; int cur = 0 ; lp(i,0,t) { int k = str[i] - 'a' ; if(trie[cur][k] == 0) trie[cur][k] = ++cnt ; cur = trie[cur][k] ; } marc[cur] =true; } void dfs(int x) { if(marc[x]) printf("P\n") ; int ok= -1 ; lp(i,0,26) { if( trie[x][i] == separa ) { ok = i+'a' ; continue ; } if(trie[x][i] == 0) continue ; printf("%c\n", i+'a') ; dfs( trie[x][i] ) ; printf("-\n"); } if(ok!=-1) { printf("%c\n", ok) ; dfs(separa++) ; } } int main() { scanf("%d", &n); string v[MAXN] ; cin>>v[0] ; lp(i,1,n) { cin>>v[i] ; if( v[i].size() > v[0].size() ) swap(v[0] , v[i]) ; } lp(i,0,n) add(v[i]) ; printf("%d\n" ,cnt*2 + n - v[0].size() ) ; dfs(0) ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1152 KB | Output is correct |
2 | Correct | 3 ms | 1536 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1792 KB | Output is correct |
2 | Correct | 5 ms | 2048 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3712 KB | Output is correct |
2 | Correct | 18 ms | 6912 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 7936 KB | Output is correct |
2 | Correct | 13 ms | 2660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 18396 KB | Output is correct |
2 | Correct | 132 ms | 41336 KB | Output is correct |
3 | Correct | 70 ms | 22264 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 14456 KB | Output is correct |
2 | Correct | 136 ms | 49016 KB | Output is correct |
3 | Correct | 77 ms | 25080 KB | Output is correct |
4 | Correct | 118 ms | 46456 KB | Output is correct |