| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 492753 | erik_kl1 | Type Printer (IOI08_printer) | C++11 | 120 ms | 102168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F0R(i, n) for(int i = 0; i < (n); i++)
using namespace std;
ostringstream os;
struct node {
int term_cnt;
bool marked;
node *nex[26];
node() {
term_cnt = 0;
marked = 0;
F0R(i,26)
nex[i] = NULL;
}
};
struct trie {
node rt;
void insert(string s) {
node *cur = &rt;
F0R(i,s.size()) {
if(cur->nex[s[i]-'a'] == NULL)
cur->nex[s[i]-'a'] = new node();
cur = cur->nex[s[i]-'a'];
}
cur->term_cnt++;
}
void mark(string s) {
node *cur = &rt;
F0R(i,s.size()) {
cur = cur->nex[s[i]-'a'];
cur->marked = 1;
}
}
}
t;
int dfs(node *v) {
int ret = v->term_cnt;
F0R(i,ret)
os << "P\n";
F0R(i,26) if(v->nex[i] != NULL && !v->nex[i]->marked) {
os << ((char) (i+'a')) << '\n';
ret += dfs(v->nex[i]);
os << "-\n";
ret += 2;
}
F0R(i,26) if(v->nex[i] != NULL && v->nex[i]->marked) {
os << ((char) (i+'a')) << '\n';
ret += dfs(v->nex[i]);
ret++;
}
return ret;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int N; cin >> N;
string longest = "";
F0R(i,N) {
string s; cin >> s;
t.insert(s);
if(s.size() > longest.size())
longest = s;
}
t.mark(longest);
cout << dfs(&t.rt) << '\n';
cout << os.str();
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... | ||||
