| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 107464 | tictaccat | Type Printer (IOI08_printer) | C++14 | 16 ms | 7936 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 25000 + 10;
int N;
vector<string> words;
string longest;
vector<vector<int>> trie(MAX,vector<int>(26));
vector<int> hasString(MAX);
int c = 0; //current max node in tree
ostringstream oss;
int ops;
void insert (const string &s) {
int u = 0;
for (int i = 0; i < s.size(); i++) {
if (trie[u][s[i]-'a']) u = trie[u][s[i]-'a'];
else u = trie[u][s[i]-'a'] = ++c;
}
hasString[u] = true;
}
void dfs(int u, int adv) {
if (hasString[u]) {
ops++;
oss << "P\n";
}
if (adv == longest.size()) {
cout << ops << "\n" << oss.str();
exit(0);
}
for (int c = 0; c < 26; c++) {
if (c == longest[adv]-'a') continue;
if (trie[u][c]) {
ops++;
oss << (char)('a'+c) << "\n";
dfs(trie[u][c],adv);
}
}
if (trie[u][longest[adv]-'a']) {
ops++;
oss << longest[adv] << "\n";
dfs(trie[u][longest[adv]-'a'],adv+1);
}
ops++;
oss << "-\n";
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
for (int i = 0; i < N; i++) {
string w; cin >> w;
words.push_back(w);
insert(w);
}
longest = *max_element(words.begin(),words.end(),[](string a, string b) {return a.size() < b.size();});
dfs(0,0);
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... | ||||
