# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957569 | 2024-04-04T04:06:51 Z | hirayuu_oj | Type Printer (IOI08_printer) | C++17 | 49 ms | 7880 KB |
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,a,b) for(int i=a; i<(b); i++) #define all(x) x.begin(),x.end() using ll=long long; const int INF=INT_MAX>>1; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector<string> s(n); rep(i,n){ cin>>s[i]; } string mx=""; rep(i,n){ if(mx.size()<s[i].size()){ mx=s[i]; } } vector<pair<int,string>> ns(n); rep(i,n){ ns[i].second=s[i]; ns[i].first=0; rep(j,s[i].size()){ if(s[i][j]==mx[j]){ ns[i].first++; } else{ break; } } } sort(all(ns)); rep(i,n){ s[i]=ns[i].second; } vector<char> ans; for(char i:s[0]){ ans.push_back(i); } ans.push_back('P'); rep(i,n-1){ ll ng=0; rep(j,min(s[i].size(),s[i+1].size())){ if(s[i][j]==s[i+1][j]){ ng++; } else{ break; } } rep(j,s[i].size()-ng){ ans.push_back('-'); } rep2(j,ng,s[i+1].size()){ ans.push_back(s[i+1][j]); } ans.push_back('P'); } std::cout<<ans.size()<<"\n"; for(char i:ans){ std::cout<<i<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 452 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 516 KB | Output is correct |
2 | Correct | 0 ms | 456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 856 KB | Output is correct |
2 | Correct | 7 ms | 1368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 1748 KB | Output is correct |
2 | Correct | 6 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 3528 KB | Output is correct |
2 | Correct | 34 ms | 6608 KB | Output is correct |
3 | Correct | 26 ms | 5588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 3168 KB | Output is correct |
2 | Correct | 41 ms | 7880 KB | Output is correct |
3 | Correct | 29 ms | 6360 KB | Output is correct |
4 | Correct | 49 ms | 7528 KB | Output is correct |