# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164262 | 2019-11-18T21:00:23 Z | kimbj0709 | Type Printer (IOI08_printer) | C++17 | 120 ms | 4792 KB |
#include <bits/stdc++.h> using namespace std; #define int long long string longest; bool comp(string a,string b){ int lpa = 0,lpb = 0; for(int i=0;i<a.length();i++){ if(a.at(i)==longest.at(i)){ lpa++; } else{ break; } } for(int i=0;i<b.length();i++){ if(b.at(i)==longest.at(i)){ lpb++; } else{ break; } } if(lpa>lpb){ return 0; } else if(lpa<lpb){ return 1; } else{ return a<b; } } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); string input; vector<string> vect1; int no_of_input; vector<char> ans; cin >> no_of_input; for(int i=0;i<no_of_input;i++){ cin >> input; vect1.push_back(input); if(input.length()>longest.length()){ longest = input; } } sort(vect1.begin(),vect1.end(),comp); string rn = ""; for(int i=0;i<vect1.size();i++){ string curr = vect1[i]; while(rn.length()>curr.length()){ ans.push_back('-'); rn.pop_back(); } for(int j=0;j<rn.length();j++){ if(rn.at(j)!=curr.at(j)){ for(int k=rn.length()-1;k>=j;k--){ ans.push_back('-'); rn.pop_back(); } goto cont; } } cont : ; for(int j=rn.length();j<curr.length();j++){ ans.push_back(curr.at(j)); rn += curr.at(j); } ans.push_back('P'); } cout << ans.size() << "\n"; for(auto k:ans){ cout << k << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 760 KB | Output is correct |
2 | Correct | 20 ms | 1048 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 1276 KB | Output is correct |
2 | Correct | 39 ms | 1048 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 2576 KB | Output is correct |
2 | Correct | 96 ms | 4072 KB | Output is correct |
3 | Correct | 76 ms | 3436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 2492 KB | Output is correct |
2 | Correct | 120 ms | 4792 KB | Output is correct |
3 | Correct | 84 ms | 3824 KB | Output is correct |
4 | Correct | 108 ms | 4588 KB | Output is correct |