# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957559 | 2024-04-04T03:22:52 Z | hirayuu_oj | Type Printer (IOI08_printer) | C++17 | 35 ms | 8620 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]; } sort(all(s)); rep(i,n){ s.push_back(s[i]); } rep(i,n){ s.push_back(s[i]); } int mx=-INF; int pos=0; rep(i,n){ ll ng=0; rep(j,min(s[i].size(),s[i+1].size())){ if(s[i][j]==s[i+1][j]){ ng++; } else{ break; } } int now=(s[i].size()+s[i+1].size()-ng*2)-s[i+1].size(); if(mx<now){ mx=now; pos=i+1; } } vector<char> ans; for(char i:s[pos]){ ans.push_back(i); } ans.push_back('P'); rep2(i,pos,pos+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'); } cout<<ans.size()<<"\n"; for(char i:ans){ cout<<i<<"\n"; } }
Compilation message
# | 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 | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 928 KB | Output is correct |
2 | Incorrect | 10 ms | 1828 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 2056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 4280 KB | Output is correct |
2 | Correct | 35 ms | 8620 KB | Output is correct |
3 | Incorrect | 24 ms | 7500 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 4236 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |