Submission #310772

#TimeUsernameProblemLanguageResultExecution timeMemory
310772sofapudenType Printer (IOI08_printer)C++14
0 / 100
55 ms3788 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<string> v(n); for(auto &x : v)cin >> x; vector<vector<string>> out(21); vector<int> used(n,0); int ls = -1, lsn = 0; for(int i = 0; i < n; ++i){ if((int)v[i].size() > lsn){ lsn = v[i].size(); ls = i; } } cout << v[ls] << "\n"; for(int i = 0; i < lsn; ++i){ for(int j = 0; j < n; ++j){ if(used[j])continue; if((int)v[j].size() < i){out[i].push_back(v[j]);used[j] = 1;} if(v[ls][i] != v[j][i]){out[i].push_back(v[j]);used[j] = 1;} } } for(int i = 0; i < n; ++i){ if(!used[i])out[20].push_back(v[i]); } for(int i = 0; i < 21; ++i){ sort(out[i].begin(),out[i].end()); } string cur; vector<char> oututo; for(auto x : out){ for(auto y : x){ int go = min(cur.size(),y.size()); for(int i = 0; i < min((int)cur.size(),(int)y.size()); ++i){ if(cur[i] != y[i]){go = i; break;} } while(go < (int)cur.size()){ cur.pop_back(); oututo.push_back('-'); } for(int i = go; i < (int)y.size(); ++i){ oututo.push_back(y[i]); cur+=y[i]; } oututo.push_back('P'); } } cout << oututo.size() << "\n"; for(auto x : oututo)cout << x << "\n"; }
#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...