# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551254 | 2022-04-20T07:04:05 Z | ToroTN | Type Printer (IOI08_printer) | C++14 | 170 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; int t,trie[500005][27],n,node,cnt=0,hsh[500005],mx=-1,print=0; char s[25],phero[25]; vector<char> krit; void dfs(int u,int lv) { if(hsh[u]!=0) { krit.push_back('P'); ++print; } for(int i=0;i<26;i++) { if('a'+i!=phero[lv]) if(trie[u][i]!=-1) { krit.push_back('a'+i); dfs(trie[u][i],lv+1); if(print!=t) krit.push_back('-'); } } if(trie[u][phero[lv]-'a']!=-1) { krit.push_back(phero[lv]); dfs(trie[u][phero[lv]-'a'],lv+1); if(print!=t) krit.push_back('-'); } } int main() { memset(trie,-1,sizeof trie); scanf("%d",&t); for(int j=1;j<=t;j++) { scanf("%s",s+1); n=0; for(int i=1;s[i];i++)++n; node=0; for(int i=1;i<=n;i++) { if(trie[node][s[i]-'a']==-1) { ++cnt; trie[node][s[i]-'a']=cnt; } node=trie[node][s[i]-'a']; } hsh[node]=j; if(n>mx) { mx=n; for(int i=1;i<=n;i++)phero[i]=s[i]; } } dfs(0,1); printf("%d\n",krit.size()); for(int i=0;i<krit.size();i++) { printf("%c\n",krit[i]); } } /* 3 print the poem */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 53076 KB | Output is correct |
2 | Runtime error | 170 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 53144 KB | Output is correct |
2 | Correct | 21 ms | 53100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 53044 KB | Output is correct |
2 | Correct | 21 ms | 53124 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 53080 KB | Output is correct |
2 | Correct | 20 ms | 53076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 53244 KB | Output is correct |
2 | Incorrect | 21 ms | 53152 KB | Line " |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 53224 KB | Output is correct |
2 | Correct | 21 ms | 53200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 53460 KB | Line " |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 53960 KB | Output is correct |
2 | Incorrect | 27 ms | 53424 KB | Line " |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 52 ms | 55008 KB | Line " |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 71 ms | 54680 KB | Output is correct |
2 | Incorrect | 107 ms | 57864 KB | Line " |
3 | Halted | 0 ms | 0 KB | - |