# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
546867 | ussef_abdallah | Type Printer (IOI08_printer) | C++14 | 56 ms | 5572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int common(string &x, string &y) {
int mn = min(x.length(), y.length());
int cnt = 0;
for (int i = 0; i < mn; i++) {
if (x[i] == y[i])
cnt++;
else
break;
}
return cnt;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<string> a(n);
string longest = "";
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i].length() > longest.length())
longest = a[i];
}
sort(a.begin(), a.end(), [&](string &x, string &y) {
int commonX = common(x, longest);
int commonY = common(y, longest);
if (commonX == commonY)
return x < y;
return commonX < commonY;
});
string cur = "";
vector<char> ans;
for (string &s : a) {
int sPtr = 0, curPtr = 0;
while (curPtr < cur.length() && sPtr < s.length()
&& cur[curPtr] == s[sPtr]) {
curPtr++;
sPtr++;
}
for (int j = cur.length() - 1; j >= curPtr; j--) {
cur.pop_back();
ans.push_back('-');
}
while (sPtr < s.length()) {
ans.push_back(s[sPtr]);
cur += s[sPtr];
sPtr++;
}
ans.push_back('P');
}
cout << ans.size() << '\n';
for (char &c : ans) {
cout << c << "\n";
}
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... |