#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#define F first
#define S second
#define loop(i, s, e) for (int i = s; i <= e; i++)
#define zep(i, n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define comp(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define sz(x) (int)((x).size())
#define sq(x) (x) * (x)
#define srt(x) sort(all(x))
#define pb push_back
#define eb emplace_back
#define d2(name, x, y) vector<vector<int> > name(x); for (auto &each : name) each.resize(y)
#define d3(name, x, y, z) vector<vector<vector<int> > > name(x); for (auto &each : name) { each.resize(y); for (auto &each_ : each) each_.resize(z); }
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define imp cout << "-1\n"
#define el cout << "\n"
const int MAX = 1e5 + 5;
const int LOG = 20;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dx[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
void Solve(int N)
{
vector<int> M(N), ans(N), used(N);
loop(i, 0, N - 1) M[i] = 1;
int endval = -1;
loop(i, 0, N - 1)
{
M[i] = 0;
int x = Query(M);
M[i] = 1;
if (x == 1)
{
endval = i;
break;
}
}
ans[0] = endval;
used[endval] = 1;
loop(i, 1, N - 1)
{
// ans[i]의 값 찾기
loop(j, 0, N - 1) M[j] = 0;
// M[ans[i - 1]] = 1;
int l = i, r = N - 1;
l -= i; r -= i;
while (l < r)
{
int mid = (l + r) / 2;
// l ~ mid, mid+1 ~ r
// mid - l + 1, r - mid
int idx = 0, cnt = 0;
while (cnt < mid - l + 1)
{
if (!used[idx]) { M[idx] = 1; cnt++; }
idx++;
}
int x = Query(M);
M[ans[i - 1]] = 1; int y = Query(M); M[ans[i - 1]] = 0;
idx = 0, cnt = 0;
loop(i, 0, N - 1) M[i] = 0;
if (x == y) r = mid;
else l = mid + 1;
}
int idx = 0, cnt = 0, v = -1;
while (cnt < l + 1)
{
if (!used[idx]) { v = idx; cnt++; }
idx++;
}
used[v] = 1; ans[i] = v;
}
for (auto &each : ans) each++;
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
200 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
200 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |