# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164261 | 2019-11-18T20:59:34 Z | kimbj0709 | Type Printer (IOI08_printer) | C++17 | 171 ms | 5212 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() { 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 | 256 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 360 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 632 KB | Output is correct |
2 | Correct | 31 ms | 1140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 1460 KB | Output is correct |
2 | Correct | 35 ms | 1140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 2720 KB | Output is correct |
2 | Correct | 150 ms | 4436 KB | Output is correct |
3 | Correct | 128 ms | 3820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 2724 KB | Output is correct |
2 | Correct | 171 ms | 5212 KB | Output is correct |
3 | Correct | 126 ms | 4276 KB | Output is correct |
4 | Correct | 159 ms | 5096 KB | Output is correct |