# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1019944 | 2024-07-11T11:01:44 Z | cproko | Type Printer (IOI08_printer) | C++14 | 41 ms | 38664 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define vec vector #define PB push_back #define all(x) x.begin(), x.end() #define F first #define S second #define int long long #define ull unsigned long long #define pii pair<int,int> #define rz resize #define yes cout << "YES\n" #define no cout << "NO\n" const int N = 1e5 + 5; const ll INF = 1e9 + 5; const ll MOD = 1e9 + 7; int n, cnt=0; string ans; struct Node { Node* child[26]; int exist; bool mark; Node() { exist=0; mark=false; for (int i = 0; i < 26; ++i) child[i] = NULL; } }; void insert(string &s, Node* root) { Node* cur = root; for (char c : s) { if (cur->child[c - 'a'] == NULL) { cur->child[c - 'a'] = new Node(); } cur = cur->child[c - 'a']; } cur->exist++; } void mark(string &s, Node* root) { Node* cur = root; for (char c : s) { cur = cur->child[c - 'a']; cur->mark=true; } } void dfs1(Node* u) { if (u->exist) ans+= 'P'; for (int i=0; i<26; ++i) { if (u->child[i] != NULL) { if (u->child[i]->mark) continue; ans+= (char)(i+'a'); dfs1(u->child[i]); ans+='-'; } } for (int i=0; i<26; ++i) { if(u->child[i]==NULL) continue; if (u->child[i]->mark) { ans+=(char)(i+'a'); dfs1(u->child[i]); } } } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); Node* root = new Node(); int n; cin >> n; int lge=0; string maxS; for (int i=0; i<n; ++i) { string s; cin >> s; insert(s, root); if (s.size() > lge) lge=s.size(), maxS=s; } mark(maxS, root); dfs1(root); cout << ans.size() << '\n' << ans; cerr << "Run!\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Line "tptttykduyvxjbzhqupP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Line "eejzatjmnqxctnP--------------h...-yerxP----labfaryosskugbkiuffdP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Line "hjxgqkP------iupqiqP------rhpq...------------wPfxlmwfirlgbdevjdP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Line "bhvdxrpthaP----------edczvdgoy...--------------xomsgennpdlurnmvP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Line "abbblauqkfdP----------edP--svh...----ooP--ulwzP----eynorwrbizaiP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1884 KB | Line "aPaisxlhagqbjwbP-------------b...----------zP-cclviwgdudcybahuwP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 6380 KB | Line "aPacaoP---izjpfrpvhbP---------...------silP---zuknicjtukmwmlddzP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 15592 KB | Line "aPadmeP---ejuixzggakP---------...----vP-wshP---gPkwzakqubhstcdqP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 38664 KB | Line "aPaadfP--iznyxP-----nqjP----bo...------------nhbvobjbxuwlhzwchfP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 30204 KB | Line "aPaPbakyloxqrjP----------chfaP...vpiP--------jbfbP---jtearnhdjeP" doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |