# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
855060 | vjudge1 | Type Printer (IOI08_printer) | C++17 | 25 ms | 3028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define _for(ccc, sss, eee) for (int ccc=(sss);ccc<=(eee);ccc++)
#define __for(ccc, sss, eee) for (int ccc=(sss);ccc>=(eee);ccc--)
#define N 25000
#define INF 0x7f7f7f7f
stringstream ss;
int n, same_ind;
bool first=true;
string cur, in[N+10], _="-", P="P";
inline bool cmp(const string &a, const string &b){
if (a.size()!=b.size())return a.size()<b.size();
return a<b;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);//如果写freopen()删掉cout.tie()
cin>>n;
_for (i, 0, n-1)cin>>in[i];
sort(in, in+n, cmp);
_for (i, 0, n-1){
if (first){
same_ind=0;
first=false;
}
else{
for (same_ind=0;same_ind<min(cur.size(), in[i].size()) &&
cur[same_ind]==in[i][same_ind];same_ind++);
_for (j, 1, max(cur.size(), in[i].size())-same_ind-1)ss<<_;
}
_for (j, same_ind, in[i].size()-1)ss<<in[i][j];
ss<<P;
cur=in[i];
}
string out;
ss>>out;
cout<<out.size()<<"\n";
for (auto &cur:out)cout<<cur<<"\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |