# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303723 | 2020-09-20T15:12:32 Z | FlashGamezzz | Type Printer (IOI08_printer) | C++17 | 1000 ms | 134564 KB |
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <string> #include <utility> #include <vector> #include <queue> using namespace std; vector< vector<long> > lets; vector< vector<int> > has; vector<bool> endb; vector<int> length; vector<char> ans; void add(long c, int i, string s){ if (i == s.length()){ endb[c] = true; length[c] = max(0, length[c]); return; } int l = int(s[i])-97; if (lets[c][l] == 0){ vector<long> t; for (int j = 0; j < 26; j++) t.push_back(0); lets.push_back(t); endb.push_back(false); length.push_back(-100); has.push_back(vector<int>()); has[c].push_back(l); lets[c][l] = lets.size()-1; } add(lets[c][l], i+1, s); length[c] = max(length[lets[c][l]]+1, length[c]); } void solve(long c){ if (endb[c]){ ans.push_back('P'); } vector< pair<int, int> > ls; for (int a : has[c]){ ls.push_back(make_pair(length[lets[c][a]], a)); } sort(ls.begin(), ls.end()); for (pair<int, int> a : ls){ ans.push_back(char(a.second+97)); solve(lets[c][a.second]); ans.push_back('-'); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<long> t; for (int j = 0; j < 26; j++) t.push_back(0); lets.push_back(t); endb.push_back(false); length.push_back(-100); for (int i = 0; i < n; i++){ string s; cin >> s; add(0, 0, s); } solve(0); long count = ans.size(); while (ans[count-1] == '-'){ count--; } cout << count << endl; for (int i = 0; i < count; i++){ cout << ans[i] << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 512 KB | Output is correct |
2 | Correct | 21 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 2432 KB | Output is correct |
2 | Correct | 49 ms | 3004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 8084 KB | Output is correct |
2 | Correct | 307 ms | 16844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 363 ms | 19864 KB | Output is correct |
2 | Correct | 100 ms | 4336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 914 ms | 49724 KB | Output is correct |
2 | Execution timed out | 1097 ms | 113412 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 754 ms | 38744 KB | Output is correct |
2 | Execution timed out | 1100 ms | 134564 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |