답안 #252647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252647 2020-07-26T03:32:47 Z yuma220284 Type Printer (IOI08_printer) C++14
30 / 100
668 ms 2832 KB
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];
	sort(S.begin(), S.end());
	int ANS = N + S[0].size() + S[N - 1].size();
	for (int i = 0; i < N - 1; i++) {
		int X = 0;
		for (int j = 0; j < S[i].size() && j < S[i + 1].size(); j++) {
			if (S[i][j] == S[i + 1][j]) X++;
			else break;
		}
		ANS += S[i].size() + S[i + 1].size() - X * 2;
	}
	int MAX = -1, ID = -1;
	for (int i = 0; i < N; i++) {
		if (MAX < (int)S[i].size()) MAX = S[i].size(), ID = i;
	}
	cout << ANS - MAX << endl;
	vector<string> T;
	for (int i = ID + 1; i < N; i++) T.push_back(S[i]);
	for (int i = 0; i <= ID; i++) T.push_back(S[i]);
	for (int i = 0; i < T[0].size(); i++) cout << T[0][i] << endl;
	cout << 'P' << endl;
	for (int i = 0; i < N - 1; i++) {
		int X = 0;
		for (int j = 0; j < T[i].size() && j < T[i + 1].size(); j++) {
			if (T[i][j] == T[i + 1][j]) X++;
			else break;
		}
		for (int j = X; j < T[i].size(); j++) cout << '-' << endl;
		for (int j = X; j < T[i + 1].size(); j++) cout << T[i + 1][j] << endl;
		cout << 'P' << endl;
	}
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:13:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < S[i].size() && j < S[i + 1].size(); j++) {
                   ~~^~~~~~~~~~~~~
printer.cpp:13:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < S[i].size() && j < S[i + 1].size(); j++) {
                                      ~~^~~~~~~~~~~~~~~~~
printer.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < T[0].size(); i++) cout << T[0][i] << endl;
                  ~~^~~~~~~~~~~~~
printer.cpp:31:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < T[i].size() && j < T[i + 1].size(); j++) {
                   ~~^~~~~~~~~~~~~
printer.cpp:31:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < T[i].size() && j < T[i + 1].size(); j++) {
                                      ~~^~~~~~~~~~~~~~~~~
printer.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = X; j < T[i].size(); j++) cout << '-' << endl;
                   ~~^~~~~~~~~~~~~
printer.cpp:36:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = X; j < T[i + 1].size(); j++) cout << T[i + 1][j] << endl;
                   ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 512 KB Expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 768 KB Output is correct
2 Incorrect 233 ms 1252 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 258 ms 1404 KB Expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 668 ms 2832 KB Expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 553 ms 2796 KB Expected EOF
2 Halted 0 ms 0 KB -