Submission #410872

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