# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314384 | 2020-10-19T19:03:46 Z | ShiftyBlock | Type Printer (IOI08_printer) | C++11 | 94 ms | 5868 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++) #define endl "\n" 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); } } pair<int, string> arr[25001]; char s[25001][21]; int main() { setIO("printer", 0); int N; scanf("%d", &N); v<int> sim; sim.push_back(0); int worst=0; for (int i = 0; i < N; ++i) { scanf("%s",s[i]); if(strlen(s[worst])<strlen(s[i])){ worst=i; } } rep(i,0,N){ int same=0; rep(j,0, strlen(s[i])){ if(s[worst][j]==s[i][j]) same++; else break; } arr[i]= make_pair( same, s[i]); } sort(arr,arr+N ); v<char> res; rep(i, 0,N){ int len=arr[i].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 plen= arr[i-1].s.size(); 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 | 1280 KB | Output is correct |
2 | Correct | 1 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1280 KB | Output is correct |
2 | Correct | 1 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1280 KB | Output is correct |
2 | Correct | 1 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1280 KB | Output is correct |
2 | Correct | 1 ms | 1312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1280 KB | Output is correct |
2 | Correct | 2 ms | 1408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1408 KB | Output is correct |
2 | Correct | 3 ms | 1408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1664 KB | Output is correct |
2 | Correct | 13 ms | 2048 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 2048 KB | Output is correct |
2 | Correct | 11 ms | 1920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 3056 KB | Output is correct |
2 | Correct | 74 ms | 5232 KB | Output is correct |
3 | Correct | 40 ms | 4080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 2804 KB | Output is correct |
2 | Correct | 94 ms | 5868 KB | Output is correct |
3 | Correct | 48 ms | 4596 KB | Output is correct |
4 | Correct | 79 ms | 5744 KB | Output is correct |