# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652021 | 2022-10-21T06:57:11 Z | Vladth11 | Type Printer (IOI08_printer) | C++14 | 115 ms | 49344 KB |
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" using namespace std; const int NMAX = 1000001; string acum; struct Node{ int nxt[26]; int cnt; void init(){ cnt = 0; for(int i = 0; i < 26; i++){ nxt[i] = -1; } } }v[NMAX]; int cnt; vector <char> sol; string maxim; void DFS(int node, int ramura, int k){ if(v[node].cnt > 0) sol.push_back('P'); if(k == maxim.size()) return; for(int i = 0; i < 26; i++){ if(v[node].nxt[i] != -1){ int param = ramura; if(param == 1 && i != maxim[k] - 'a') param = 0; if(param == 1) continue; sol.push_back('a' + i); DFS(v[node].nxt[i], param, k + 1); sol.push_back('-'); } } if(ramura == 0 && k < maxim.size()) return; int ch = maxim[k] - 'a'; sol.push_back(maxim[k]); DFS(v[node].nxt[ch], ramura, k + 1); } void baga(int node, int k){ if(k == acum.size()){ v[node].cnt++; return; } int ch = acum[k] - 'a'; if(v[node].nxt[ch] == -1){ v[node].nxt[ch] = ++cnt; v[cnt].init(); } baga(v[node].nxt[ch], k + 1); } int main() { int sz = 0; int t; v[0].init(); cin >> t; while(t--){ string s; cin >> s; if(s.size() > sz){ sz = s.size(); maxim = s; } acum = s; baga(0, 0); } DFS(0, 1, 0); cout << sol.size() << "\n"; for(auto x : sol) cout << x << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 980 KB | Output is correct |
2 | Correct | 3 ms | 1236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3028 KB | Output is correct |
2 | Correct | 14 ms | 6352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 7504 KB | Output is correct |
2 | Correct | 9 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 18264 KB | Output is correct |
2 | Correct | 96 ms | 41536 KB | Output is correct |
3 | Correct | 56 ms | 21368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 14304 KB | Output is correct |
2 | Correct | 115 ms | 49344 KB | Output is correct |
3 | Correct | 75 ms | 24336 KB | Output is correct |
4 | Correct | 103 ms | 46564 KB | Output is correct |