답안 #118070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118070 2019-06-18T06:17:02 Z baluteshih Type Printer (IOI08_printer) C++14
30 / 100
51 ms 4928 KB
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s[25005],output,nw;
int ned[25005];

int main()
{jizz
	int n,L;
	cin >> n;
	s[0]="";
	for(int i=1;i<=n;++i)
		cin >> s[i];
	sort(s,s+n+1);
	s[0]=s[n];
	for(int i=1;i<=n;++i)
	{
		ned[i]=s[i-1].size()-2*min(s[i-1].size(),s[i].size());
		for(int j=0;j<s[i-1].size()&&j<s[i].size();++j)
			if(s[i-1][j]!=s[i][j])
			{
				ned[i]=s[i-1].size()-j-j;
				break;
			}
	}
	int p=max_element(ned+1,ned+n+1)-ned;
	for(int i=p;i<=n;++i)
	{
		L=min(nw.size(),s[i].size());
		for(int j=0;j<nw.size()&&j<s[i].size();++j)
			if(nw[j]!=s[i][j])
			{
				L=j;
				break;
			}
		for(int j=L;j<nw.size();++j)
			output.pb('-');
		for(int j=L;j<s[i].size();++j)
			output.pb(s[i][j]);
		output.pb('P'),nw=s[i];
	}
	for(int i=1;i<p;++i)
	{
		L=nw.size();
		for(int j=0;j<nw.size()&&j<s[i].size();++j)
			if(nw[j]!=s[i][j])
			{
				L=j;
				break;
			}
		for(int j=L;j<nw.size();++j)
			output.pb('-');
		for(int j=L;j<s[i].size();++j)
			output.pb(s[i][j]);
		output.pb('P'),nw=s[i];
	}
	cout << output.size() << "\n";
	for(auto c:output)
		cout << c << "\n";
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<s[i-1].size()&&j<s[i].size();++j)
               ~^~~~~~~~~~~~~~
printer.cpp:31:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<s[i-1].size()&&j<s[i].size();++j)
                                ~^~~~~~~~~~~~
printer.cpp:42:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<nw.size()&&j<s[i].size();++j)
               ~^~~~~~~~~~
printer.cpp:42:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<nw.size()&&j<s[i].size();++j)
                            ~^~~~~~~~~~~~
printer.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<nw.size();++j)
               ~^~~~~~~~~~
printer.cpp:50:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<s[i].size();++j)
               ~^~~~~~~~~~~~
printer.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<nw.size()&&j<s[i].size();++j)
               ~^~~~~~~~~~
printer.cpp:57:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<nw.size()&&j<s[i].size();++j)
                            ~^~~~~~~~~~~~
printer.cpp:63:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<nw.size();++j)
               ~^~~~~~~~~~
printer.cpp:65:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<s[i].size();++j)
               ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Incorrect 3 ms 1072 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Correct 3 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1408 KB Output is correct
2 Incorrect 11 ms 1792 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 2584 KB Output is correct
2 Correct 51 ms 4928 KB Output is correct
3 Incorrect 32 ms 3988 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 2196 KB Output isn't correct
2 Halted 0 ms 0 KB -