#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int nbElem)
{
vector<int> ret(nbElem);
if (nbElem == 1)
{
ret[0] = 1;
Answer(ret);
return ;
}
vector<int> tabRequete(nbElem,1);
int extremGauche=-1;
for (int i(0); i < nbElem; ++i)
{
tabRequete[i] = 0;
int query = Query(tabRequete);
tabRequete[i] = 1;
if (query == 1)
{
extremGauche = i;
break;
}
}
fill(tabRequete.begin(), tabRequete.end(), 0);
tabRequete[extremGauche] = 1;
vector<int> restant;
for (int i(0); i < nbElem; ++i)
if (i != extremGauche)
restant.push_back(i);
ret[0] = extremGauche;
for (int i(1); i < nbElem; ++i)
{
int deb(0), fin((int)restant.size()-1);
while (deb < fin)
{
int mid = (deb + fin) / 2;
tabRequete.assign(nbElem, 0);
for (int iReq(deb); iReq <= mid; ++iReq)
tabRequete[restant[iReq]] = 1;
int retSans = Query(tabRequete);
tabRequete[ret[i-1]] = 1;
int retAvec = Query(tabRequete);
if (retAvec == retSans)
fin = mid;
else
deb = mid+1;
}
ret[i] = restant[deb];
restant.erase(lower_bound(restant.begin(), restant.end(), restant[deb]));
}
for (auto &v : ret) v++;
Answer(ret);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
364 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
40 ms |
492 KB |
# of queries: 2593 |
5 |
Correct |
40 ms |
364 KB |
# of queries: 2504 |
6 |
Correct |
36 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
38 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
39 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
36 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
15 ms |
376 KB |
# of queries: 1478 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 73 |
16 |
Correct |
3 ms |
364 KB |
# of queries: 187 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
364 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
40 ms |
492 KB |
# of queries: 2593 |
5 |
Correct |
40 ms |
364 KB |
# of queries: 2504 |
6 |
Correct |
36 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
38 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
39 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
36 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
15 ms |
376 KB |
# of queries: 1478 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 73 |
16 |
Correct |
3 ms |
364 KB |
# of queries: 187 |
17 |
Correct |
290 ms |
364 KB |
# of queries: 18008 |
18 |
Correct |
292 ms |
364 KB |
# of queries: 17231 |
19 |
Correct |
305 ms |
364 KB |
# of queries: 17451 |
20 |
Correct |
277 ms |
364 KB |
# of queries: 16277 |
21 |
Correct |
267 ms |
364 KB |
# of queries: 15362 |
22 |
Correct |
358 ms |
364 KB |
# of queries: 17617 |
23 |
Correct |
313 ms |
364 KB |
# of queries: 17170 |
24 |
Correct |
106 ms |
364 KB |
# of queries: 7885 |
25 |
Correct |
309 ms |
364 KB |
# of queries: 17118 |
26 |
Correct |
303 ms |
364 KB |
# of queries: 15989 |
27 |
Correct |
124 ms |
364 KB |
# of queries: 7994 |
28 |
Correct |
290 ms |
364 KB |
# of queries: 17935 |
29 |
Correct |
341 ms |
364 KB |
# of queries: 17915 |
30 |
Correct |
372 ms |
364 KB |
# of queries: 17935 |