Submission #282874

# Submission time Handle Problem Language Result Execution time Memory
282874 2020-08-25T06:11:49 Z kshitij_sodani Hidden Sequence (info1cup18_hidden) C++14
59 / 100
8 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second


#include "grader.h"
//#define  ask isSubsequence
int st=0;
bool ask(vector<int> kk){
/*	if(st){
		for(int i=0;i<kk.size();i++){
			kk[i]=1-kk[i];
		}
	}*/
	return isSubsequence(kk);
}
vector <int> findSequence (int n){
   	vector<int> ans;

	vector<int> kk;

   	for(int i=0;i<(n+1)/2;i++){
   		kk.pb(1);
   	}
   	st=0;
   	if(ask(kk)){
   		st=0;
   		//0 in minority
   	}
   	else{
   		st=1;
   		//1 in minority
   	}
   	vector<int> ii;
   	for(int i=0;i<n/2;i++){
   		ii.pb(st);
   		if(ask(ii)){
   			continue;
   		}
   		else{
   			ii.pop_back();
   			break;
   		}
   	}
   	if(ii.size()==0){
   		for(int i=0;i<n;i++){
   			ans.pb(1-st);
   		}
   		return ans;
   	}
   	int le=n-ii.size();
   	int ind=-1;
   	vector<int> co;
   	for(int i=0;i<ii.size()+1;i++){
   		co.pb(0);
   	}
   	for(int i=0;i<ii.size()+1;i++){
   		vector<int> cc;
   		for(int j=0;j<i;j++){
   			cc.pb(st);
   		}
   		for(int k=1;k<=(le/2)+1;k++){
   			vector<int> dd=cc;
   			for(int j=0;j<k;j++){
   				dd.pb(1-st);
   			}
   			for(int j=i;j<ii.size();j++){
   				dd.pb(st);
   			}
   			if(ask(dd)){
   				co[i]+=1;
   				if(k==(le/2)+1){
   					ind=i;
   					break;
   				}
   			}
   			else{
   				break;
   			}

   		}
   	}
   	int su=ii.size();
   	for(auto i:co){
   		su+=i;
   	}
   	if(ind>=-1){
   		co[ind]+=(n-su);
   	}
   	for(int i=0;i<ii.size();i++){
   		for(int j=0;j<co[i];j++){
   			ans.pb(1-st);
   		}
   		ans.pb(st);
   	}
   	for(int j=0;j<co.back();j++){
   		ans.pb(1-st);
   	}
 /*  	for(auto j:co){
   		cout<<j<<":";
   	}
   	cout<<endl;
   	cout<<ii.size()<<endl;
   	*/






   










    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<ii.size()+1;i++){
      |                 ~^~~~~~~~~~~~
hidden.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0;i<ii.size()+1;i++){
      |                 ~^~~~~~~~~~~~
hidden.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |       for(int j=i;j<ii.size();j++){
      |                   ~^~~~~~~~~~
hidden.cpp:94:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |     for(int i=0;i<ii.size();i++){
      |                 ~^~~~~~~~~~
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 256 KB Output is partially correct: Maximum length of a query = 7
2 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 8
3 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 7
4 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 7
5 Partially correct 0 ms 256 KB Output is partially correct: Maximum length of a query = 6
# Verdict Execution time Memory Grader output
1 Partially correct 5 ms 256 KB Output is partially correct: Maximum length of a query = 86
2 Partially correct 5 ms 256 KB Output is partially correct: Maximum length of a query = 92
3 Partially correct 8 ms 256 KB Output is partially correct: Maximum length of a query = 102
4 Partially correct 4 ms 256 KB Output is partially correct: Maximum length of a query = 87
5 Partially correct 4 ms 372 KB Output is partially correct: Maximum length of a query = 103
6 Partially correct 6 ms 256 KB Output is partially correct: Maximum length of a query = 130
7 Partially correct 6 ms 256 KB Output is partially correct: Maximum length of a query = 144
8 Partially correct 6 ms 256 KB Output is partially correct: Maximum length of a query = 124
9 Partially correct 7 ms 384 KB Output is partially correct: Maximum length of a query = 126
10 Partially correct 5 ms 372 KB Output is partially correct: Maximum length of a query = 125
11 Partially correct 6 ms 256 KB Output is partially correct: Maximum length of a query = 97
12 Partially correct 7 ms 384 KB Output is partially correct: Maximum length of a query = 150
13 Partially correct 7 ms 256 KB Output is partially correct: Maximum length of a query = 107