# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
321261 | vukasinbabic06 | Type Printer (IOI08_printer) | C++14 | 169 ms | 98788 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int ans = 0;
struct Node{
int last;
int is;
Node *next[26];
Node(){
last = false;
is = false;
for(int i = 0; i < 26; i++) next[i] = NULL;
}
} *root = new Node;
void insert(Node *root, string s){
for(int i = 0; i < s.size(); i++){
int index = s[i] - 'a';
if(root -> next[index] == NULL) {
root -> next[index] = new Node;
ans ++;
}
root = root -> next[index];
}
root -> last = 1;
}
void search(Node *root, string s){
for(int i = 0; i < s.size(); i++){
int index = s[i] - 'a';
root = root -> next[index];
root -> is = 1;
}
root -> last = 1;
}
void Print(Node *root){
for(int i = 0; i < 26; i++){
if(root -> next[i] != NULL && !root -> next[i] -> is){
cout << char(i + 'a')<< '\n';
if(root -> next[i] -> last) cout << "P" << '\n';
Print(root -> next[i]); cout << "-" << '\n';
}
}
}
int n;
string st;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++) {
string s;
cin >> s;
insert(root, s);
if(s.size() > st.size()) st = s;
}
search(root, st);
cout << ans * 2 + n - st.size() << '\n';
Print(root);
for(int i = 0; i < st.size(); i++){
cout << st[i] << '\n';
Print(root -> next[st[i] - 'a']);
if(root -> next[st[i] - 'a'] -> last) cout << "P" << '\n';
root = root -> next[st[i] - 'a'];
}
}
컴파일 시 표준 에러 (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... |