Submission #67301

#TimeUsernameProblemLanguageResultExecution timeMemory
67301hamzqq9Hidden Sequence (info1cup18_hidden)C++14
100 / 100
11 ms564 KiB
#include<bits/stdc++.h> #include "grader.h" #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 2000000000 #define MOD 1000000007 #define MAX 10000006 #define LOG 22 using namespace std; int MXQ; bool query(vector<int> res) { return isSubsequence(res); } int f1(int N) { for(int i=1;i<=N;i++) { vector<int> que; if(i>MXQ) { for(int j=0;j<N-i;j++) que.pb(0); bool res=query(que); if(res==true) return i-1; } else { for(int j=0;j<i;j++) que.pb(1); bool res=query(que); if(res==false) return i-1; } } return N; } vector < int > findSequence (int N) { MXQ=N/2+1; int h1=f1(N); int h0=N-h1; int p1=0; int p0=0; vector<int> ans; for(int i=0;i<N;i++) { // is it 1 vector<int> que; if(p1+1+h0<=MXQ) { for(int j=0;j<p1+1;j++) que.pb(1); for(int j=0;j<h0;j++) que.pb(0); bool res=query(que); if(res) { p1++; h1--; ans.pb(1); } else { p0++; h0--; ans.pb(0); } } else { for(int j=0;j<p0+1;j++) que.pb(0); for(int j=0;j<h1;j++) que.pb(1); bool res=query(que); if(res) { p0++; h0--; ans.pb(0); } else { p1++; h1--; ans.pb(1); } } } return ans; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...