Submission #966666

#TimeUsernameProblemLanguageResultExecution timeMemory
966666vjudge1Type Printer (IOI08_printer)C++17
0 / 100
35 ms2140 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll n; cin >> n; vector<string> p(n); for (int i=0;i<n;i++) { cin >> p[i]; } sort(p.begin(),p.end(),[](auto&x,auto&y) { if (x.substr(0,abs((signed)(x.size()-y.size()))) == y.substr(0,abs((signed)(x.size()-y.size())))) { return true; } return x.size() < y.size(); }); string curr=""; string ans=""; for (int i=0;i<n;i++) { while (curr.size() != 0 && curr != p[i].substr(0,curr.size())) { ans+="-"; curr.pop_back(); } ans+=p[i].substr(curr.size(),p[i].size()-curr.size()); curr=p[i]; ans+="P"; } n = ans.size(); for (int i=0;i<n;i++) { cout << ans[i] <<'\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...