Submission #410870

# Submission time Handle Problem Language Result Execution time Memory
410870 2021-05-23T21:02:05 Z nichke Hidden Sequence (info1cup18_hidden) C++14
0 / 100
6 ms 200 KB
#include <bits/stdc++.h>
#include <grader.h>
using namespace std;
 
bool isSubsequence(vector<int> vi);

int cnt[2];
int done[2];

vector<int> findSequence(int N) {
	vector<int> ans(N);
	vector<int> tmp;
	for (int i = 0; i < (N + 1) / 2; i++) {
		tmp.push_back(0);
		if (!isSubsequence(tmp)) break;
		cnt[0]++;
	}
	tmp.clear();
	for (int i = 0; i < (N + 1) / 2; i++) {
		tmp.push_back(1);
		if (!isSubsequence(tmp)) break;
		cnt[1]++;
	}
	if (cnt[0] < cnt[1]) {
		cnt[1] = N - cnt[0];
	} else {
		cnt[0] = N - cnt[1];
	}
	for (int i = N - 1; i >= 0; i--) {
		if (!cnt[0]) {
			ans[i] = 1; cnt[1]--;
			continue;
		}
		if (!cnt[1]) {
			ans[i] = 0; cnt[0]--;
			continue;
		}
		int bt = 1;
		if (cnt[0] + done[1] > cnt[1] + done[0]) {
			bt ^= 1;
		}
		tmp.clear();
		for (int j = 0; j < cnt[bt ^ 1]; j++) tmp.push_back(bt ^ 1);
		for (int j = 0; j < done[bt]; j++) tmp.push_back(bt);
		ans[i] = (!isSubsequence(tmp)) ^ bt;
		done[ans[i]]++; cnt[ans[i]]--;
	}
	return ans;
}

Compilation message

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:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 200 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -