| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 931366 | rahidilbayramli | Type Printer (IOI08_printer) | C++17 | 50 ms | 56300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll sz = 1e5+5;
ll triee[sz][26], value[sz], subtree[sz], next_node = 1;
map<ll, char>mp;
vector<char>res;
void add(string& s, ll id)
{
ll node = 0;
for(ll idx = 0; idx < s.size(); idx++)
{
ll ch = s[idx] - 'a';
if(!triee[node][ch]){
triee[node][ch] = next_node;
mp[next_node] = s[idx];
next_node++;
}
node = triee[node][ch];
}
value[node] = 1;
}
void dfs1(ll node = 0)
{
subtree[node] = 1;
for(ll i = 0; i < 26; i++)
{
if(triee[node][i]){
dfs1(triee[node][i]);
subtree[node] += subtree[triee[node][i]];
}
}
}
void dfs(ll node = 0)
{
if(node)
res.pb(mp[node]);
if(value[node])
res.pb('P');
vector<pll>vv;
for(ll i = 0; i < 26; i++)
{
if(triee[node][i])
vv.pb({subtree[triee[node][i]], triee[node][i]});
}
sort(all(vv));
for(ll i = 0; i < vv.size(); i++)
dfs(vv[i].s);
res.pb('-');
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll tests = 1;
//cin >> tests;
while(tests--)
{
ll n, i;
cin >> n;
for(i = 1; i <= n; i++)
{
string s;
cin >> s;
add(s, i);
}
dfs1();
dfs();
while(res.back() == '-')
res.pop_back();
cout << res.size() << "\n";
for(auto u : res)
cout << u << "\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... | ||||
