| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1031740 | doducanh | Type Printer (IOI08_printer) | C++14 | 73 ms | 56848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e6+7;
string res="";string maxs="";
struct trie
{
int cnt=0;
int t[maxn][30];
int stop[maxn];
void add(string &s){
int curr=0;
for(char c:s){
if(t[curr][c-'a'+1]==0)t[curr][c-'a'+1]=++cnt;
curr=t[curr][c-'a'+1];
}
stop[curr]++;
}
void dfs(int curr,bool type,int depth=-1){
while(stop[curr]--){
res.push_back('P');
}
if(depth==maxs.size()-1)return;
if(type==0){
for(int i=1; i<=26; i++)
{
if(t[curr][i]) {
res.push_back((char)i-1+'a');
dfs(t[curr][i],0,depth+1);
res.push_back('-');
}
}
}
else{
for(int i=1; i<=26; i++)
{
if(i==(maxs[depth+1]-'a'+1))continue;
if(t[curr][i]) {
res.push_back((char)i-1+'a');
dfs(t[curr][i],0,depth+1);
res.push_back('-');
}
}
if(depth+1<maxs.size())res.push_back(maxs[depth+1]);
if(t[curr][maxs[depth+1]-'a'+1])dfs(t[curr][maxs[depth+1]-'a'+1],1,depth+1);
}
}
};
trie t;
int n;
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
string s;
cin>>s;
if(s.size()>maxs.size())maxs=s;
t.add(s);
}
t.dfs(0,1);
cout<<res.size()<<"\n";
for(char c:res)cout<<c<<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
