이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int last = 0;
bool ask(int x) {
int nw = Query(x);
bool g = (last != nw);
last = nw;
return g;
}
void solve(vector<int> a, vector<int> b, bool f) {
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size();
int mid = (int) max(1.0, n * 0.4);
vector<int> la, lb, ra, rb;
for (int i = 0; i < n; i++) {
if (i < mid) ask(b[i]), lb.push_back(b[i]);
else rb.push_back(b[i]);
}
for (int i : a) {
if (la.size() == mid) ra.push_back(i);
else if (ra.size() == n - mid) la.push_back(i);
else if (f) {
if (ask(i)) ra.push_back(i);
else la.push_back(i);
} else {
if (ask(i)) la.push_back(i);
else ra.push_back(i);
}
}
solve(la, lb, f ^ 1);
solve(ra, rb, f);
}
void Solve(int N) {
vector<int> a, b;
for (int i = 1; i <= 2 * N; i++) {
if (ask(i)) a.push_back(i);
else b.push_back(i);
}
solve(a, b, 0);
}
컴파일 시 표준 에러 (stderr) 메시지
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | if (la.size() == mid) ra.push_back(i);
| ~~~~~~~~~~^~~~~~
minerals.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | else if (ra.size() == n - mid) la.push_back(i);
| ~~~~~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |