| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 519035 | AdamGS | Type Printer (IOI08_printer) | C++17 | 65 ms | 7512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=25e3+7, INF=1e9+7;
string T[LIM], P[LIM];
int lcp(string a, string b) {
int ans=0;
while(ans<a.size() && ans<b.size() && a[ans]==b[ans]) ++ans;
return ans;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
rep(i, n) cin >> T[i];
sort(T, T+n);
pair<int,int>ma={-1, -1};
rep(i, n) {
pair<int,int>p={T[i].size(), i};
ma=max(ma, p);
}
P[0]=T[ma.nd];
int mi1=0, mi2=0, p1=ma.nd-1, p2=ma.nd+1;
if(p1>=0) mi1=lcp(P[0], T[p1]);
else mi1=-1;
if(p2<n) mi2=lcp(P[0], T[p2]);
else mi2=-1;
rep(i, n-1) {
if(mi1>=mi2) {
P[i+1]=T[p1];
--p1;
if(p1>=0) mi1=lcp(P[0], T[p1]);
else mi1=-1;
} else {
P[i+1]=T[p2];
++p2;
if(p2<n) mi2=lcp(P[0], T[p2]);
else mi2=-1;
}
}
reverse(P, P+n);
string x="";
vector<char>ans;
rep(i, n) {
int p=lcp(x, P[i]);
while(x.size()>p) {
ans.pb('-');
x.pop_back();
}
while(x.size()<P[i].size()) {
ans.pb(P[i][x.size()]);
x+=P[i][x.size()];
}
ans.pb('P');
}
cout << ans.size() << '\n';
for(auto i : ans) cout << i << '\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... | ||||
