# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782798 | 2023-07-14T09:36:58 Z | canadavid1 | Type Printer (IOI08_printer) | C++14 | 1000 ms | 2536 KB |
#include <bits/stdc++.h> using namespace std; #define all(x) begin(x),end(x) using i32 = int32_t; using i64 = int64_t; int common_substring(string a,string b) { if(a.size() < b.size()) swap(a,b); for(int i = b.size()-1;i >= 0; i--) { if(a.substr(0,i)==b.substr(0,i)) return i; } return 0; } int main() { cin.tie(nullptr)->sync_with_stdio(false); i32 N; cin >> N; vector<string> words(N); for(int i = 0; i < N; i++) { cin >> words[i]; } sort(all(words)); string min_ops = ""; do { string curr = ""; string ops = ""; for(auto i : words) { i32 l = common_substring(curr,i); while(curr.size()>l) { curr.pop_back(); ops.push_back('-'); } curr += i.substr(l); ops += i.substr(l); ops.push_back('P'); } if(min_ops.size()==0||ops.size() < min_ops.size()) min_ops = ops; } while(next_permutation(all(words))); cout << min_ops.size() << "\n"; for(auto i : min_ops) cout << i << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 300 KB | Output is correct |
2 | Correct | 628 ms | 296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1061 ms | 316 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1046 ms | 1320 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1058 ms | 2536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1052 ms | 2504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |