# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314343 | 2020-10-19T18:20:34 Z | ShiftyBlock | Type Printer (IOI08_printer) | C++11 | 1000 ms | 5180 KB |
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pii pair<int, int> #define long long long #define v vector #define rep(i,a,b) for(int i=a; i<b; i++) void setIO(string name, int submit) { if (submit) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } else{ ios_base::sync_with_stdio(0); cin.tie(0); } } int main() { setIO("printer", 0); int N; cin>>N; v<pair<int,string>> arr; v<int> sim; sim.push_back(0); int worst=0; for (int i = 0; i < N; ++i) { string line; cin>>line; arr.push_back(make_pair(0,line)); if(arr[worst].s.size()<line.size()){ worst=i; } } rep(i,0,N){ int same=0; rep(j,0, min(arr[i].s.size(), arr[worst].s.size())){ if(arr[i].s[j]==arr[worst].s[j]) same++; else break; } arr[i].f=same; } sort(arr.begin(), arr.end()); v<char> res; rep(i, 0,N){ int len=arr[i].s.size(); int plen=arr[i-1].s.size(); //cout<<arr[i].f<<endl; if(i==0){ rep(j,0,len){ res.push_back(arr[i].s[j]); } res.push_back('P'); } else{ int same=0; rep(j,0,min(len,plen)){ if(arr[i].s[j]!=arr[i-1].s[j]) break; same++; } rep(j,0, plen-same) { res.push_back('-'); } rep(j,same, len){ res.push_back(arr[i].s[j]); } res.push_back('P'); } } cout<<res.size()<<endl; for(char x: res){ cout<<x<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 22 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 384 KB | Output is correct |
2 | Correct | 39 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 112 ms | 740 KB | Output is correct |
2 | Correct | 248 ms | 1092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 288 ms | 1376 KB | Output is correct |
2 | Correct | 88 ms | 1276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 736 ms | 2812 KB | Output is correct |
2 | Execution timed out | 1083 ms | 4680 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 591 ms | 2664 KB | Output is correct |
2 | Execution timed out | 1088 ms | 5180 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |