Submission #588709

#TimeUsernameProblemLanguageResultExecution timeMemory
588709Bench0310Type Printer (IOI08_printer)C++17
100 / 100
51 ms7304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<string> s(n); array<int,2> m={0,0}; for(int i=0;i<n;i++) { cin >> s[i]; m=max(m,{int(s[i].size()),i}); } vector<pair<int,string>> v(n); for(int i=0;i<n;i++) { int c=-1; while(c+1<(int)s[i].size()&&s[i][c+1]==s[m[1]][c+1]) c++; v[i]={c+1,s[i]}; } sort(v.begin(),v.end()); string now; string res; for(auto [c,t]:v) { int len=-1; while(len+1<int(min(now.size(),t.size()))&&now[len+1]==t[len+1]) len++; res+=string((int)now.size()-(len+1),'-'); for(int i=len+1;i<(int)t.size();i++) res+=t[i]; res+='P'; now=t; } cout << res.size() << "\n"; for(char c:res) cout << c << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...