# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1063685 | dyogorb | Type Printer (IOI08_printer) | C++14 | 57 ms | 6748 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int WMAX = 3e4;
int trie[WMAX][26];
int node_count;
bool stop[WMAX];
string biggest;
string ans;
void insert(string word){
int node = 0;
for (char c: word)
{
if(trie[node][c - 'a'] == 0) trie[node][c - 'a'] = ++node_count;
node = trie[node][c - 'a'];
}
stop[node] = true;
}
void dfs(int node, int depth, int flag){
for (int i = 0; i < 26; i++)
{
if((i != biggest[depth] - 'a' || !flag) && trie[node][i]){
char c = 'a' + i;
ans += c;
if(stop[trie[node][i]]) ans += 'P';
dfs(trie[node][i], depth + 1, 0);
ans += '-';
}
}
if(trie[node][biggest[depth] - 'a'] && flag){
ans += biggest[depth];
if(depth == biggest.size() - 1) ans += 'P';
dfs(trie[node][biggest[depth] - 'a'], depth + 1, 1);
}
}
int main(){
int n;
cin >> n;
string s;
biggest = "";
for (int i = 0; i < n; i++)
{
cin >> s;
insert(s);
if(s.size() > biggest.size()) biggest = s;
}
dfs(0, 0, 1);
cout << ans.size() << endl;
for (auto c : ans)
{
cout << c << endl;
}
}
컴파일 시 표준 에러 (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... |