#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
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++)
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
2 ms |
436 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
2 ms |
436 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
2 ms |
452 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
2 ms |
452 KB |
Output is correct: Maximum length of a query = 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
452 KB |
Output is correct: Maximum length of a query = 83 |
2 |
Correct |
39 ms |
532 KB |
Output is correct: Maximum length of a query = 90 |
3 |
Correct |
20 ms |
532 KB |
Output is correct: Maximum length of a query = 96 |
4 |
Correct |
25 ms |
536 KB |
Output is correct: Maximum length of a query = 77 |
5 |
Correct |
13 ms |
544 KB |
Output is correct: Maximum length of a query = 95 |
6 |
Correct |
6 ms |
560 KB |
Output is correct: Maximum length of a query = 87 |
7 |
Correct |
30 ms |
560 KB |
Output is correct: Maximum length of a query = 97 |
8 |
Correct |
21 ms |
568 KB |
Output is correct: Maximum length of a query = 83 |
9 |
Correct |
57 ms |
568 KB |
Output is correct: Maximum length of a query = 101 |
10 |
Correct |
66 ms |
568 KB |
Output is correct: Maximum length of a query = 100 |
11 |
Correct |
10 ms |
580 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Correct |
8 ms |
580 KB |
Output is correct: Maximum length of a query = 100 |
13 |
Correct |
34 ms |
588 KB |
Output is correct: Maximum length of a query = 101 |