Submission #127411

# Submission time Handle Problem Language Result Execution time Memory
127411 2019-07-09T10:46:22 Z E869120 Hidden Sequence (info1cup18_hidden) C++14
59 / 100
13 ms 400 KB
#include <iostream>
#include <vector>
#include "grader.h"
using namespace std;

int sum[109];

vector<int> findSequence (int N) {
	int zero = 0, one = 0;
	for (int i = 1; i <= (N + 1) / 2; i++) {
		vector<int> L0(i, 0); if (isSubsequence(L0) == true) zero++;
		vector<int> L1(i, 1); if (isSubsequence(L1) == true) one++;
	}
	if (zero < one) one = N - zero;
	else zero = N - one;
	
	if (zero < one) {
		for (int i = 0; i <= zero; i++) {
			for (int j = 1; j <= (one / 2) + 1; j++) {
				vector<int>vec;
				for (int k = 0; k <= zero; k++) {
					if (i == k) {
						for (int l = 0; l < j; l++) vec.push_back(1);
					}
					if (k < zero) vec.push_back(0);
				}
				if (isSubsequence(vec) == true) sum[i] = j;
				else break;
			}
			if (sum[i] == (one / 2) + 1) sum[i] = -1;
		}
		int rem = one;
		for (int i = 0; i <= zero; i++) { if (sum[i] != -1) rem -= sum[i]; }
		for (int i = 0; i <= zero; i++) { if (sum[i] == -1) sum[i] = rem; }

		vector<int>ans;
		for (int i = 0; i <= zero; i++) {
			for (int j = 0; j < sum[i]; j++) ans.push_back(1);
			if (i < zero) ans.push_back(0);
		}
		return ans;
	}
	else {
		for (int i = 0; i <= one; i++) {
			for (int j = 1; j <= (zero / 2) + 1; j++) {
				vector<int>vec;
				for (int k = 0; k <= one; k++) {
					if (i == k) {
						for (int l = 0; l < j; l++) vec.push_back(0);
					}
					if (k < one) vec.push_back(1);
				}
				if (isSubsequence(vec) == true) sum[i] = j;
				else break;
			}
			if (sum[i] == (zero / 2) + 1) sum[i] = -1;
		}
		int rem = zero;
		for (int i = 0; i <= one; i++) { if (sum[i] != -1) rem -= sum[i]; }
		for (int i = 0; i <= one; i++) { if (sum[i] == -1) sum[i] = rem; }

		vector<int>ans;
		for (int i = 0; i <= one; i++) {
			for (int j = 0; j < sum[i]; j++) ans.push_back(0);
			if (i < one) ans.push_back(1);
		}
		return ans;
	}
}

Compilation message

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 Partially correct 2 ms 248 KB Output is partially correct: Maximum length of a query = 7
2 Partially correct 13 ms 248 KB Output is partially correct: Maximum length of a query = 8
3 Partially correct 2 ms 248 KB Output is partially correct: Maximum length of a query = 7
4 Partially correct 2 ms 276 KB Output is partially correct: Maximum length of a query = 7
5 Partially correct 2 ms 380 KB Output is partially correct: Maximum length of a query = 6
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 248 KB Output is partially correct: Maximum length of a query = 86
2 Partially correct 8 ms 376 KB Output is partially correct: Maximum length of a query = 92
3 Partially correct 10 ms 248 KB Output is partially correct: Maximum length of a query = 102
4 Partially correct 7 ms 248 KB Output is partially correct: Maximum length of a query = 87
5 Partially correct 9 ms 248 KB Output is partially correct: Maximum length of a query = 102
6 Partially correct 8 ms 376 KB Output is partially correct: Maximum length of a query = 130
7 Partially correct 8 ms 376 KB Output is partially correct: Maximum length of a query = 144
8 Partially correct 7 ms 248 KB Output is partially correct: Maximum length of a query = 97
9 Partially correct 7 ms 400 KB Output is partially correct: Maximum length of a query = 114
10 Partially correct 10 ms 396 KB Output is partially correct: Maximum length of a query = 125
11 Partially correct 6 ms 312 KB Output is partially correct: Maximum length of a query = 97
12 Partially correct 9 ms 248 KB Output is partially correct: Maximum length of a query = 150
13 Partially correct 10 ms 376 KB Output is partially correct: Maximum length of a query = 106