Submission #973828

# Submission time Handle Problem Language Result Execution time Memory
973828 2024-05-02T11:32:14 Z LCJLY Hidden Sequence (info1cup18_hidden) C++14
59 / 100
77 ms 848 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

//code
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<long long,long long>pii;
typedef pair<int,pii>pi2;
vector<int> findSequence(int n){
	int lim=(n*3/4)+1;
	int half=n/2;
	vector<int>v,v2;
	for(int x=0;x<half+1;x++){
		v.push_back(0);
		v2.push_back(1);
	}
	bool amos=isSubsequence(v);
	int flip=0;
	if(amos){
		flip=1;
	}
	v.clear();
	while(isSubsequence(v)){
		v.push_back(0^flip);
	}
	v.pop_back();
	
	//fill in gaps
	bool done[n+5];
	memset(done,0,sizeof(done));
	int cnt[n+5];
	memset(cnt,0,sizeof(cnt));
	for(int x=0;x<=(int)v.size();x++){
		//show(x,x);
		for(int i=1;i+(int)v.size()<lim;i++){
			v2.clear();
			//show(i,i);
			for(int j=0;j<x;j++){
				v2.push_back(0^flip);
			}
			//show(check,1);
			for(int j=0;j<i;j++){
				v2.push_back(1^flip);
			}
			//show(check,2);
			for(int j=0;j<(int)v.size()-x;j++){
				v2.push_back(0^flip);
			}
			//show4(v2,v2);
			bool hold=isSubsequence(v2);
			if(!hold) done[x]=true;
			else cnt[x]=i;
		}
	}
	
	int counter=v.size();
	for(int x=0;x<n;x++){
		counter+=cnt[x];
	}
	for(int x=0;x<=(int)v.size();x++){
		if(!done[x]){
			cnt[x]+=n-counter;
		}
	}
	
	vector<int>ans;
	for(int x=0;x<=(int)v.size();x++){
		for(int y=0;y<cnt[x];y++){
			ans.push_back(1^flip);
		}
		if(x!=(int)v.size()){
			ans.push_back(0^flip);
		}
	}
	return ans;
}

//code

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 Partially correct 1 ms 344 KB Output is partially correct: Maximum length of a query = 6
2 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 7
3 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 6
4 Partially correct 1 ms 344 KB Output is partially correct: Maximum length of a query = 6
5 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 5
# Verdict Execution time Memory Grader output
1 Partially correct 38 ms 436 KB Output is partially correct: Maximum length of a query = 123
2 Partially correct 58 ms 696 KB Output is partially correct: Maximum length of a query = 133
3 Partially correct 54 ms 848 KB Output is partially correct: Maximum length of a query = 142
4 Partially correct 32 ms 440 KB Output is partially correct: Maximum length of a query = 114
5 Partially correct 61 ms 696 KB Output is partially correct: Maximum length of a query = 141
6 Partially correct 52 ms 696 KB Output is partially correct: Maximum length of a query = 129
7 Partially correct 70 ms 440 KB Output is partially correct: Maximum length of a query = 144
8 Partially correct 38 ms 436 KB Output is partially correct: Maximum length of a query = 123
9 Partially correct 77 ms 440 KB Output is partially correct: Maximum length of a query = 150
10 Partially correct 65 ms 436 KB Output is partially correct: Maximum length of a query = 149
11 Partially correct 61 ms 440 KB Output is partially correct: Maximum length of a query = 142
12 Partially correct 68 ms 696 KB Output is partially correct: Maximum length of a query = 149
13 Partially correct 70 ms 700 KB Output is partially correct: Maximum length of a query = 150