# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
819014 | 2023-08-10T07:38:28 Z | Sir_Ahmed_Imran | Type Printer (IOI08_printer) | C++17 | 110 ms | 98548 KB |
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define li long int #define ld long double #define append push_back #define add insert #define nl "\n" #define ff first #define ss second #define pii pair<int,int> #define pic pair<int,char> #define all(x) (x).begin(),(x).end() #define sum(a) accumulate(all(a),0) #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL) #define terminator main #define MAXN 100001 class TrieNode { public: int z; bool prt; TrieNode* nxt[26]; TrieNode(){ for(int i=prt=z=0;i<26;i++) nxt[i]=NULL; } }; class Trie{ public: TrieNode* root; int siz; Trie(){ siz=0; root=new TrieNode(); } void insert(string a){ int m; TrieNode* x=root; for(int i=0;i<a.size();i++){ m=a[i]-'a'; if(!x->nxt[m]){ siz++; x->nxt[m]=new TrieNode(); } x=x->nxt[m]; if(a.size()>x->z) x->z=a.size(); } x->prt=1; } void dfs(TrieNode* x){ vector<pii> v; for(int i=0;i<26;i++) if(x->nxt[i]) v.append({x->nxt[i]->z,i}); sort(all(v)); for(auto& i:v){ siz--; cout<<char(i.ss+'a')<<nl; if(x->nxt[i.ss]->prt){ siz--; cout<<'P'<<nl; } dfs(x->nxt[i.ss]); if(siz>0) cout<<'-'<<nl; siz--; } } }; void solve(){ string a; int n,m,o,p,q; Trie x; cin>>n; for(int i=m=0;i<n;i++){ cin>>a; x.insert(a); if(a.size()>m) m=a.size(); } x.siz=x.siz*2+n-m; cout<<x.siz<<nl; x.dfs(x.root); } int terminator(){ L0TA; solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 316 KB | Output is correct |
2 | Correct | 0 ms | 320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 1108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1740 KB | Output is correct |
2 | Correct | 4 ms | 2120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5844 KB | Output is correct |
2 | Correct | 16 ms | 12240 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 14528 KB | Output is correct |
2 | Correct | 6 ms | 3284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 36148 KB | Output is correct |
2 | Correct | 92 ms | 82896 KB | Output is correct |
3 | Correct | 50 ms | 42588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 28236 KB | Output is correct |
2 | Correct | 110 ms | 98548 KB | Output is correct |
3 | Correct | 58 ms | 48432 KB | Output is correct |
4 | Correct | 98 ms | 93044 KB | Output is correct |