Submission #1143029

#TimeUsernameProblemLanguageResultExecution timeMemory
1143029AgageldiHidden Sequence (info1cup18_hidden)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "grader.cpp"
#include "grader.h"

#define pb push_back
#define sz(s) (int)s.size()
using namespace std;

int n, m, a[500];
vector <int> ask, bir, nol;
string s, g;

vector < int > findSequence (int N)
{
	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < 1000; i++) {
		bir.push_back(1);
		nol.push_back(0);
		if (!isSubsequence(bir)) {
			cnt1 = i;
			cnt0 = N - cnt1;
			break;
		}
		if(!isSubsequence(nol)) {
			cnt0 = i;
			cnt1 = N - cnt0;
			break;
		}
	}
	bir.clear();
	int tr = 0;
	while(cnt1 > 0 && cnt0 > 0) {
		ask.clear();
		if(cnt0 < cnt1 || cnt0 == cnt1 && tr == 2) {
			ask.pb(1);
			tr = 1;
			for(int i = 1; i <= cnt0; i++) {
				ask.pb(0);
			}
			if(!isSubsequence(ask)) {
				bir.pb(0);
				cnt0--;
			}
			else {
				bir.pb(1);
				cnt1--;
			}
			continue;
		}
		tr = 2;
		ask.pb(0);
		for(int i = 1; i <= cnt1; i++) {
			ask.pb(1);
		}	
		if(isSubsequence(ask)) {
			bir.pb(0);
			cnt0--;
		}
		else {
			bir.pb(1);
			cnt1--;
		}
	}
	while(cnt1--) bir.pb(1);
	while(cnt0--) bir.pb(0);
	return bir;
}

Compilation message (stderr)

In file included from hidden.cpp:2:
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
/usr/bin/ld: /tmp/cc4zk4K1.o: in function `isSubsequence(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `isSubsequence(std::vector<int, std::allocator<int> >)'; /tmp/ccWzxRSR.o:hidden.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/cc4zk4K1.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWzxRSR.o:hidden.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status