#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int nbElem)
{
cerr << "HEY"<<endl;
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);
for (auto v : restant)
cerr << v + 1 << ' ';
cerr << endl;
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++;
for (auto v: ret) cerr << v << ' ';
cerr << endl;
Answer(ret);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
114 ms |
492 KB |
# of queries: 2433 |
3 |
Correct |
126 ms |
492 KB |
# of queries: 2638 |
4 |
Correct |
128 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
125 ms |
416 KB |
# of queries: 2504 |
6 |
Correct |
129 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
133 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
116 ms |
492 KB |
# of queries: 2402 |
9 |
Correct |
126 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
60 ms |
492 KB |
# of queries: 1478 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 73 |
16 |
Correct |
5 ms |
364 KB |
# of queries: 187 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
114 ms |
492 KB |
# of queries: 2433 |
3 |
Correct |
126 ms |
492 KB |
# of queries: 2638 |
4 |
Correct |
128 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
125 ms |
416 KB |
# of queries: 2504 |
6 |
Correct |
129 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
133 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
116 ms |
492 KB |
# of queries: 2402 |
9 |
Correct |
126 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
60 ms |
492 KB |
# of queries: 1478 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 73 |
16 |
Correct |
5 ms |
364 KB |
# of queries: 187 |
17 |
Execution timed out |
2528 ms |
2676 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |