# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
766934 | ParsaS | Library (JOI18_library) | C++17 | 265 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int N = 1000 + 5;
void Solve(int n)
{
vector<int> res(n);
if (n == 1) {
res[0] = 1;
Answer(res);
return;
}
for (int i = 0; i < n; i++) {
vector<int> M(n, 1);
assert(M[0]);
M[i] = 0;
int x = Query(M);
if (x == 1)
res[0] = i;
}
vector<int> A(n, 1);
A[res[0]] = 0;
for (int i = 1; i < n; i++) {
vector<int> B(n);
int cnt = 0;
for (int j = 0; j < n; j++)
B[j] = A[j], cnt += B[j];
while (cnt > 1) {
int c = 0;
vector<int> M(n, 0);
for (int j = 0; j < n; j++) {
if (c < cnt / 2 && B[j])
M[j] = 1, c++;
}
int x = Query(M);
M[res[i - 1]] = 1;
int y = Query(M);
int k = 0;
vector<int> C(n);
if (x == y) {
c = 0;
for (int j = 0; j < n; j++) {
if (c < cnt / 2 && B[j])
C[j] = 1, k++;
c += B[j];
}
}
else {
c = 0;
for (int j = 0; j < n; j++) {
if (c >= cnt / 2 && B[j])
C[j] = 1, k++;
c += B[j];
}
}
B = C;
cnt = k;
}
for (int j = 0; j < n; j++)
if (B[j])
res[i] = j, A[j] = 0;
}
for (int j = 0; j < n; j++)
++res[j];
Answer(res);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |