Submission #118065

# Submission time Handle Problem Language Result Execution time Memory
118065 2019-06-18T06:07:03 Z baluteshih Type Printer (IOI08_printer) C++14
20 / 100
29 ms 2764 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)
		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)
	{
		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)
	{
		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:29: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:29: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:38: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:38: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:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<nw.size();++j)
               ~^~~~~~~~~~
printer.cpp:46:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<s[i].size();++j)
               ~^~~~~~~~~~~~
printer.cpp:52: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:52: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:58:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<nw.size();++j)
               ~^~~~~~~~~~
printer.cpp:60:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=L;j<s[i].size();++j)
               ~^~~~~~~~~~~~
printer.cpp:58:16: warning: 'L' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for(int j=L;j<nw.size();++j)
               ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Correct 3 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Incorrect 3 ms 1180 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2332 KB Output isn't correct
2 Halted 0 ms 0 KB -