#include <bits/stdc++.h>
#define MAX_N 1000
//#include "library.h"
using namespace std;
int Query(const std::vector<int>& M);
void Answer(const std::vector<int>& res);
int n;
vector <int> tmp;
vector <int> rez;
int done[MAX_N + 1];
void divide(int st, int dr, int poz)
{
//cout << " SUNTEM " << st << " " << dr << " " << poz << "\n";
if(st == dr)
{
done[st - 1] = 1;
rez[poz + 1] = st;
return;
}
int mid = (dr + st) >> 1;
int cate = 0;
for(int i = st; i <= mid; i ++)
tmp[i - 1] = 1 - done[i - 1], cate += tmp[i - 1];
for(int i = mid + 1; i <= dr; i ++)
tmp[i - 1] = 0;
int x = 0, y = 1;
if(cate != 0)
{
x = Query(tmp);
tmp[rez[poz] - 1] = 1;
y = Query(tmp);
}
for(int i = st; i <= dr; i ++)
tmp[i - 1] = 0;
tmp[rez[poz] - 1] = 0;
y == x ? divide(st, mid, poz) : divide(mid + 1, dr, poz);
}
void Solve(int N)
{
n = N;
tmp.resize(N);
rez.resize(N);
for(int i = 0; i < n; i++)
tmp[i] = 1;
for(int i = 0; i < n; i ++)
{
tmp[i] = 0;
int x = Query(tmp);
if(x == 1)
{
done[i] = 1;
rez[0] = i + 1;
break;
}
tmp[i] = 1;
}
//cout << rez[0] << "\n";
for(int i = 1; i < n; i ++)
{
for(int j = 0; j < n; j ++)
tmp[j] = 0;
divide(1, n, i - 1);
}
/* for(int i = 0; i < n; i ++)
cout << rez[i] << " ";
cout << "\n";*/
Answer(rez);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
256 KB |
# of queries: 2749 |
2 |
Correct |
49 ms |
256 KB |
# of queries: 2787 |
3 |
Correct |
67 ms |
256 KB |
# of queries: 3004 |
4 |
Correct |
36 ms |
256 KB |
# of queries: 2921 |
5 |
Correct |
49 ms |
256 KB |
# of queries: 2868 |
6 |
Correct |
51 ms |
256 KB |
# of queries: 2919 |
7 |
Correct |
48 ms |
384 KB |
# of queries: 2908 |
8 |
Correct |
38 ms |
256 KB |
# of queries: 2742 |
9 |
Correct |
46 ms |
256 KB |
# of queries: 2880 |
10 |
Correct |
25 ms |
256 KB |
# of queries: 1628 |
11 |
Incorrect |
1 ms |
256 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
256 KB |
# of queries: 2749 |
2 |
Correct |
49 ms |
256 KB |
# of queries: 2787 |
3 |
Correct |
67 ms |
256 KB |
# of queries: 3004 |
4 |
Correct |
36 ms |
256 KB |
# of queries: 2921 |
5 |
Correct |
49 ms |
256 KB |
# of queries: 2868 |
6 |
Correct |
51 ms |
256 KB |
# of queries: 2919 |
7 |
Correct |
48 ms |
384 KB |
# of queries: 2908 |
8 |
Correct |
38 ms |
256 KB |
# of queries: 2742 |
9 |
Correct |
46 ms |
256 KB |
# of queries: 2880 |
10 |
Correct |
25 ms |
256 KB |
# of queries: 1628 |
11 |
Incorrect |
1 ms |
256 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |