Submission #410873

# Submission time Handle Problem Language Result Execution time Memory
410873 2021-05-23T21:04:56 Z nichke Hidden Sequence (info1cup18_hidden) C++14
100 / 100
9 ms 328 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 / 2; i++) {
		tmp.push_back(0);
		if (!isSubsequence(tmp)) break;
		cnt[0]++;
	}
	tmp.clear();
	for (int i = 0; i <= N / 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);
		tmp.push_back(bt);
		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 Correct 2 ms 200 KB Output is correct: Maximum length of a query = 5
2 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 6
3 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 5
4 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 5
5 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 4
# Verdict Execution time Memory Grader output
1 Correct 7 ms 200 KB Output is correct: Maximum length of a query = 83
2 Correct 7 ms 200 KB Output is correct: Maximum length of a query = 90
3 Correct 8 ms 200 KB Output is correct: Maximum length of a query = 96
4 Correct 6 ms 200 KB Output is correct: Maximum length of a query = 77
5 Correct 6 ms 296 KB Output is correct: Maximum length of a query = 95
6 Correct 6 ms 200 KB Output is correct: Maximum length of a query = 87
7 Correct 8 ms 328 KB Output is correct: Maximum length of a query = 97
8 Correct 6 ms 200 KB Output is correct: Maximum length of a query = 83
9 Correct 8 ms 200 KB Output is correct: Maximum length of a query = 101
10 Correct 9 ms 200 KB Output is correct: Maximum length of a query = 100
11 Correct 8 ms 200 KB Output is correct: Maximum length of a query = 96
12 Correct 7 ms 200 KB Output is correct: Maximum length of a query = 100
13 Correct 8 ms 284 KB Output is correct: Maximum length of a query = 101