답안 #855060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855060 2023-09-30T02:58:55 Z vjudge1 Type Printer (IOI08_printer) C++17
0 / 100
25 ms 3028 KB
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
#define fi first
#define se second
#define _for(ccc, sss, eee) for (int ccc=(sss);ccc<=(eee);ccc++)
#define __for(ccc, sss, eee) for (int ccc=(sss);ccc>=(eee);ccc--)

#define N 25000
#define INF 0x7f7f7f7f

stringstream ss;
int n, same_ind;
bool first=true;
string cur, in[N+10], _="-", P="P";
inline bool cmp(const string &a, const string &b){
	if (a.size()!=b.size())return a.size()<b.size();
	return a<b;
}
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);//如果写freopen()删掉cout.tie()
	
	cin>>n;
	_for (i, 0, n-1)cin>>in[i];
	sort(in, in+n, cmp);
	
	_for (i, 0, n-1){
		if (first){
			same_ind=0;
			first=false;
		}
		else{
			for (same_ind=0;same_ind<min(cur.size(), in[i].size()) && 
			cur[same_ind]==in[i][same_ind];same_ind++);
			_for (j, 1, max(cur.size(), in[i].size())-same_ind-1)ss<<_;
		}
		_for (j, same_ind, in[i].size()-1)ss<<in[i][j];
		ss<<P;
		cur=in[i];
	}
	string out;
	ss>>out;
	cout<<out.size()<<"\n";
	for (auto &cur:out)cout<<cur<<"\n";
	return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:38:28: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   38 |    for (same_ind=0;same_ind<min(cur.size(), in[i].size()) &&
      |                    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:11:51: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   11 | #define _for(ccc, sss, eee) for (int ccc=(sss);ccc<=(eee);ccc++)
      |                                                   ^
printer.cpp:40:4: note: in expansion of macro '_for'
   40 |    _for (j, 1, max(cur.size(), in[i].size())-same_ind-1)ss<<_;
      |    ^~~~
printer.cpp:11:51: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define _for(ccc, sss, eee) for (int ccc=(sss);ccc<=(eee);ccc++)
      |                                                   ^
printer.cpp:42:3: note: in expansion of macro '_for'
   42 |   _for (j, same_ind, in[i].size()-1)ss<<in[i][j];
      |   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1116 KB printed invalid word
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1112 KB too many deletions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1136 KB too many deletions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1112 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1116 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1116 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1368 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1752 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 3028 KB printed invalid word
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 2520 KB printed invalid word
2 Halted 0 ms 0 KB -