# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
468496 | 2021-08-28T15:28:55 Z | mariowong | Type Printer (IOI08_printer) | C++14 | 58 ms | 19232 KB |
#include <bits/stdc++.h> #define hmod (long long)1223334444555553 using namespace std; int n,len,mx,indx,cnt,now,tmp,sum; string s[25005],str; char node[500005]; bool build,gg; vector <int> edge[500005]; bool p[500005]; vector <char> ans; void dfs(int x){ if (x != 0) ans.push_back(node[x]); if (p[x]) ans.push_back('P'); for (int i=0;i<edge[x].size();i++){ dfs(edge[x][i]); } if (now == x) gg=true; if (!gg) ans.push_back('-'); } int main(){ ios::sync_with_stdio(false); cin >> n; for (int i=1;i<=n;i++){ now=0; cin >> s[i]; len=s[i].length(); if (len > mx){ mx=len; indx=i; } for (int j=0;j<len;j++){ build=true; for (int k=0;k<edge[now].size();k++){ if (node[edge[now][k]] == s[i][j]){ now=edge[now][k]; build=false; } } if (build){ edge[now].push_back(++cnt); node[cnt]=s[i][j]; now=cnt; } } p[now]=true; } len=s[indx].length(); now=0; for (int i=0;i<len;i++){ for (int j=0;j<edge[now].size();j++){ if (node[edge[now][j]] == s[indx][i]){ tmp=edge[now][j]; edge[now].erase(edge[now].begin()+j); edge[now].push_back(tmp); now=tmp; } } } dfs(0); cout << (int)ans.size() << "\n"; for (int i=0;i<ans.size();i++){ cout << ans[i] << "\n"; } return 0; } /* 8 xxvebmc ixhvdhcjxon hsspmkly labfaryosskugbkiuffd yerx mhgpafawzhnt eejzatjmnqxctn n */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12748 KB | Output is correct |
2 | Correct | 8 ms | 12756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12756 KB | Output is correct |
2 | Correct | 8 ms | 12748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12748 KB | Output is correct |
2 | Correct | 9 ms | 12732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 12748 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12748 KB | Output is correct |
2 | Incorrect | 9 ms | 12996 KB | printed invalid word |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 13112 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 13876 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 15304 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 58 ms | 19232 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 17484 KB | printed invalid word |
2 | Halted | 0 ms | 0 KB | - |