| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 876439 | StefanL2005 | Type Printer (IOI08_printer) | C++14 | 26 ms | 2524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct LetterPoz{
int poz, length;
};
bool rule(LetterPoz A, LetterPoz B)
{
if (A.length == B.length)
return A.poz < B.poz;
return A.length < B.length;
}
int Similarities(string A, string B)
{
int lA = A.length(), lB = B.length(), nr = 0;
for (int i = 0; i < min(lA, lB); i++)
if (A[i] == B[i])
nr++;
else
break;
return nr;
}
int main()
{
int N;
cin>> N;
vector<string> To_Print(N);
vector<char> Commands;
for (int i = 0; i < N; i++)
cin>> To_Print[i];
sort(To_Print.begin(), To_Print.end());
vector<int> MaxL(26, -1);
vector<int> Poz(26, N);
vector<LetterPoz> Sorted;
for (int i = 0; i < N; i++)
{
Poz[To_Print[i][0] - 'a'] = min(Poz[To_Print[i][0] - 'a'], i);
MaxL[To_Print[i][0] - 'a'] = max(MaxL[To_Print[i][0] - 'a'], int(To_Print[i].length()));
}
for (int i = 0; i < 26; i++)
{
if (MaxL[i] != -1)
{
LetterPoz A;
A.length = MaxL[i];
A.poz = Poz[i];
Sorted.push_back(A);
}
}
sort(Sorted.begin(), Sorted.end(), rule);
string Last = "";
for (int i = 0; i < Sorted.size(); i++)
{
int poz = Sorted[i].poz;
int letter = To_Print[poz][0];
while (poz < N && To_Print[poz][0] == letter)
{
int sim = Similarities(To_Print[poz], Last);
for (int j = 0; j < Last.length()- sim; j++)
Commands.push_back('-');
for (int j = sim; j < To_Print[poz].length(); j++)
Commands.push_back(To_Print[poz][j]);
Commands.push_back('P');
Last = To_Print[poz];
poz++;
}
}
cout<< Commands.size() << "\n";
for (int i = 0; i < Commands.size(); i++)
cout<< Commands[i] << "\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... | ||||
