Submission #128827

# Submission time Handle Problem Language Result Execution time Memory
128827 2019-07-11T09:57:25 Z mohammedehab2002 Hidden Sequence (info1cup18_hidden) C++11
0 / 100
400 ms 524292 KB
#include "grader.h"
#include <vector>
using namespace std;
vector<int> v(int a,int b,int c,int d)
{
	vector<int> ret;
	while (a--)
	ret.push_back(b);
	while (c--)
	ret.push_back(d);
	return ret;
}
int cz[205];
vector<int> findSequence(int n)
{
	vector<int> z,o;
	int cnt=0;
	while (isSubsequence(z) && isSubsequence(o))
	{
		z.push_back(0);
		o.push_back(1);
	}
	if (isSubsequence(z))
	cnt=o.size()-1;
	else
	cnt=n-z.size()+1;
	for (int i=1;i<=cnt;i++)
	{
		int j=1;
		for (;i+j<=n/2+1;j++)
		{
			if (!isSubsequence(v(i,1,j,0)))
			break;
		}
		int k=1;
		for (;cnt-i+1+k<=n/2+1;k++)
		{
			if (!isSubsequence(v(k,0,cnt-i+1,1)))
			break;
		}
		if (i+j<=n/2+1)
		cz[n-cnt-j+1]++;
		else
		cz[k-1]++;
	}
	vector<int> ans;
	for (int i=0;ans.size()!=n;i++)
	{
		while (cz[i]--)
		ans.push_back(1);
		ans.push_back(0);
	}
	return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;ans.size()!=n;i++)
               ~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 993 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1079 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -