Submission #973498

# Submission time Handle Problem Language Result Execution time Memory
973498 2024-05-02T05:50:24 Z shoryu386 Hidden Sequence (info1cup18_hidden) C++17
0 / 100
5 ms 944 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

vector < int > findSequence (int N){
	
	int A = 1, B = 0;
	
	vector<int> test;
	int numA = 0;
	for (int x = 1; x <= N/2+1; x++){
		test.push_back(A);
		
		if (isSubsequence(test)){
			numA++;
		}
		else break;
	}
	
	if (numA >= N/2+1){
		swap(A, B);
		
		numA = 0;
		test.clear();
		for (int x = 1; x <= N/2+1; x++){
			test.push_back(A);
			
			if (isSubsequence(test)){
				numA++;
			}
			else break;
		}
	}
	
	int filler[numA+1]; memset(filler, 0, sizeof(filler));
	test.clear();
	
	int cap = N/4 + 1;
	int marker = -1;
	
	for (int x = 0; x <= numA; x++){
		while (true){
			filler[x]++;
			test.clear();
			
			if (filler[x] > cap){
				filler[x] = 0;
				marker = x;
				
				//cerr << "Marked " << x << "!\n";
				break;
			}
			
			for (int y = 0; y < x; y++){
				test.push_back(A);
			}
			
			for (int y = 0; y < filler[x]; y++){
				test.push_back(B);
			}
			
			for (int y = 0; y < numA - x; y++){
				test.push_back(A);
			}
			
			if (test.size() <= N && isSubsequence(test)){
				continue;
			}
			else {filler[x]--; break;}
		}
	}
	
	int numB = N-numA;
	
	if (marker != -1){
		int cursum = 0;
		for (int x = 0; x <= numA; x++){
			cursum += filler[x];
		}
		
		filler[marker] = numB - cursum;
	}
	
	test.clear();
	for (int y = 0; y < numA; y++){
		for (int z = 0; z < filler[y]; z++){
			test.push_back(B);
		}
		test.push_back(A);
	}
	for (int z = 0; z < filler[numA]; z++){
		test.push_back(B);
	}
	
	return test;
	
	
	
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:67:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |    if (test.size() <= N && isSubsequence(test)){
      |        ~~~~~~~~~~~~^~~~
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 Partially correct 1 ms 344 KB Output is partially correct: Maximum length of a query = 7
2 Partially correct 1 ms 344 KB Output is partially correct: Maximum length of a query = 8
3 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 7
4 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 7
5 Incorrect 0 ms 344 KB Output is not correct: The returned sequence does not match the hidden one
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 86
2 Partially correct 2 ms 692 KB Output is partially correct: Maximum length of a query = 92
3 Partially correct 3 ms 436 KB Output is partially correct: Maximum length of a query = 102
4 Partially correct 2 ms 700 KB Output is partially correct: Maximum length of a query = 87
5 Partially correct 3 ms 444 KB Output is partially correct: Maximum length of a query = 102
6 Partially correct 2 ms 432 KB Output is partially correct: Maximum length of a query = 130
7 Partially correct 4 ms 944 KB Output is partially correct: Maximum length of a query = 144
8 Partially correct 3 ms 692 KB Output is partially correct: Maximum length of a query = 97
9 Partially correct 4 ms 436 KB Output is partially correct: Maximum length of a query = 114
10 Partially correct 5 ms 688 KB Output is partially correct: Maximum length of a query = 125
11 Partially correct 4 ms 596 KB Output is partially correct: Maximum length of a query = 97
12 Incorrect 4 ms 692 KB Output is not correct: The returned sequence does not match the hidden one
13 Halted 0 ms 0 KB -