# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314390 | 2020-10-19T19:06:54 Z | ShiftyBlock | Type Printer (IOI08_printer) | C++11 | 94 ms | 5872 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> william_lin_is_orz_and_cute_i_love_william_lin[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; } william_lin_is_orz_and_cute_i_love_william_lin[i]= make_pair( same, s[i]); } sort(william_lin_is_orz_and_cute_i_love_william_lin,william_lin_is_orz_and_cute_i_love_william_lin+N ); v<char> res; rep(i, 0,N){ int len=william_lin_is_orz_and_cute_i_love_william_lin[i].s.size(); //cout<<william_lin_is_orz_and_cute_i_love_william_lin[i].f<<endl; if(i==0){ rep(j,0,len){ res.push_back(william_lin_is_orz_and_cute_i_love_william_lin[i].s[j]); } res.push_back('P'); } else{ int plen= william_lin_is_orz_and_cute_i_love_william_lin[i-1].s.size(); int same=0; rep(j,0,min(len,plen)){ if(william_lin_is_orz_and_cute_i_love_william_lin[i].s[j]!=william_lin_is_orz_and_cute_i_love_william_lin[i-1].s[j]) break; same++; } rep(j,0, plen-same) { res.push_back('-'); } rep(j,same, len){ res.push_back(william_lin_is_orz_and_cute_i_love_william_lin[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 | 2 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 | 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 | 1936 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 2048 KB | Output is correct |
2 | Correct | 11 ms | 1920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 3056 KB | Output is correct |
2 | Correct | 92 ms | 5096 KB | Output is correct |
3 | Correct | 48 ms | 4212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 2804 KB | Output is correct |
2 | Correct | 94 ms | 5872 KB | Output is correct |
3 | Correct | 57 ms | 4468 KB | Output is correct |
4 | Correct | 81 ms | 5612 KB | Output is correct |