# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
376443 |
2021-03-11T13:29:26 Z |
peijar |
Library (JOI18_library) |
C++17 |
|
141 ms |
620 KB |
#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[1] = 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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
380 KB |
# of queries: 2387 |
2 |
Correct |
116 ms |
380 KB |
# of queries: 2433 |
3 |
Correct |
130 ms |
492 KB |
# of queries: 2638 |
4 |
Correct |
132 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
141 ms |
524 KB |
# of queries: 2504 |
6 |
Correct |
134 ms |
492 KB |
# of queries: 2553 |
7 |
Correct |
123 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
116 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
135 ms |
620 KB |
# of queries: 2512 |
10 |
Correct |
62 ms |
492 KB |
# of queries: 1478 |
11 |
Incorrect |
1 ms |
364 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
380 KB |
# of queries: 2387 |
2 |
Correct |
116 ms |
380 KB |
# of queries: 2433 |
3 |
Correct |
130 ms |
492 KB |
# of queries: 2638 |
4 |
Correct |
132 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
141 ms |
524 KB |
# of queries: 2504 |
6 |
Correct |
134 ms |
492 KB |
# of queries: 2553 |
7 |
Correct |
123 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
116 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
135 ms |
620 KB |
# of queries: 2512 |
10 |
Correct |
62 ms |
492 KB |
# of queries: 1478 |
11 |
Incorrect |
1 ms |
364 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |