# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
534025 | __Variatto | Type Printer (IOI08_printer) | C++17 | 177 ms | 115288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int A=30;
const int MAX=25e3+10;
struct st{
st* a[A];
int kon;
};
int n;
string s[MAX];
void stworz(st *v, char c){
if(v->a[c-'a']!=nullptr)
return;
st *nowy=new st;
for(int i=0; i<A; i++)
nowy->a[i]=nullptr;
nowy->kon=0;
v->a[c-'a']=nowy;
}
void dodaj(st* r, string s){
st *x=r;
for(int i=0; i<s.size(); i++){
stworz(x, s[i]);
x=x->a[s[i]-'a'];
}
x->kon++;
}
string ost;
vector<char>wyn;
void dfs(st* v, int j){
for(int i=1; i<=v->kon; i++)
wyn.pb('P');
for(int i=0; i<A; i++){
if(i==ost[j]-'a')
continue;
if(v->a[i]!=nullptr){
wyn.pb(char(i+'a'));
dfs(v->a[i], j+1);
}
}
//return;
if(j<ost.size() && v->a[ost[j]-'a']!=nullptr){
wyn.pb(ost[j]);
dfs(v->a[ost[j]-'a'], j+1);
}
wyn.pb('-');
}
int main(){
/* ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
*/ cin>>n;
st *r=new st;
for(int i=0; i<A; i++)
r->a[i]=nullptr;
r->kon=0;
pair<int,int> maxi={0,0};
for(int i=1; i<=n; i++){
cin>>s[i];
dodaj(r, s[i]);
maxi=max(maxi, {int(s[i].size()), i});
}
ost=s[maxi.se];
dfs(r, 0);
while(wyn.size() && wyn.back()=='-')
wyn.pop_back();
cout<<wyn.size()<<"\n";
for(auto x: wyn)
cout<<x<<"\n";
}
컴파일 시 표준 에러 (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... |