# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115192 | 2019-06-06T00:08:07 Z | CaroLinda | Type Printer (IOI08_printer) | C++14 | 5 ms | 896 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 = 25005; const int ALF= 30; using namespace std ; int n ; int trie[MAXN*20][ALF] , cnt ; int separa = 1 ; vector<char> ans ; bool marc[MAXN*20] ; void add( char str[] ) { int t = strlen(str) ; 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]) ans.pb('P') ; vector<pair<int,char> > v ; lp(i,0,26) if(trie[x][i] != 0) v.pb( pii(trie[x][i] , i+'a') ) ; sort( v.begin() , v.end()) ; if(v.size() == 0) return ; for(int i= v.size()-1 ; i > 0 ; i--) { ans.pb(v[i].ss) ; dfs(v[i].ff) ; ans.pb('-') ; } ans.pb(v[0].ss) ; dfs(v[0].ff) ; ans.pb('-') ; } int main() { scanf("%d", &n) ; char v[25][MAXN] ; scanf(" %s", v[0]) ; lp(i,1,n) { scanf(" %s",v[i]); if( strlen(v[i]) > strlen(v[0]) ) swap(v[i], v[0]) ; } lp(i,0,n) add(v[i]) ; printf("%d\n" , cnt*2 - strlen(v[0]) + n ) ; dfs(0) ; lp(i,0,ans.size() - strlen(v[0])) printf("%c\n" , ans[i] ) ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 512 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 768 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 768 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 768 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 896 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 768 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 768 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |