Submission #45022

#TimeUsernameProblemLanguageResultExecution timeMemory
45022zadrgaHidden Sequence (info1cup18_hidden)C++14
100 / 100
66 ms588 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second #define INF (1LL << 55) #define MOD (1000 * 1000 * 1000 + 7) #define maxn 3111 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; bool isSubsequence(vector<int> v); int pre[maxn]; bool ask(int cur, int lf, int rg){ vector<int> q; while(lf--) q.pb(cur); cur ^= 1; while(rg--) q.pb(cur); return isSubsequence(q); } vector<int> findSequence(int N){ int lim = N / 2 + 1, K = -1, less = -1; for(int i = 0; i <= N / 2; i++){ if(ask(0, i + 1, 0) == 0){ K = i; less = 0; break; } if(ask(1, i + 1, 0) == 0){ K = i; less = 1; break; } } pre[0] = 0; pre[K + 1] = N - K; for(int i = 1; i <= K; i++){ pre[i] = pre[i - 1]; bool q = 1; while(pre[i] + K + 1 - i <= lim){ q = ask(less ^ 1, pre[i], K + 1 - i); if(q == 0){ pre[i]--; break; } pre[i]++; } if(q == 0) continue; int rev = 0; while(i + rev <= lim){ q = ask(less, i, rev); if(q == 0){ rev--; break; } rev++; } if(q == 0) pre[i] = N - K - rev; else{ rev--; //in this case I'm right at half of it, and couldn't afford asking one more query pre[i] = N - K - rev; //the answer to that query, however, should've been negative anyways, so there'pre no problem actually } } for(int i = K + 1; i >= 1; i--) pre[i] -= pre[i - 1]; vector<int> ans; for(int i = 1; i <= K + 1; i++){ while(pre[i]--) ans.pb(less ^ 1); if(i != K + 1) ans.pb(less); } 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...