이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "interactive.h"
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
int first = -1;
vector<int> getNums(vector<int> a) {
vector<int> q(a.size()+1);
for (int i = 0; i < a.size(); i++) {
q[i] = a[i]+1;
}
q[a.size()] = 1;
vector<int> tot = get_pairwise_xor(q);
q.resize(a.size());
vector<int> own = get_pairwise_xor(q);
vector<int> res(2*a.size()+1);
set_difference(all(tot), all(own), res.begin());
sort(res.begin(), res.end());
res.resize(unique(res.begin(), res.end())-res.begin());
assert(res.size() == a.size()+1 && res[0] == 0);
vector<int> ret(a.size());
for (int i = 1; i < res.size(); i++) {
ret[i-1] = res[i]^first;
}
sort(all(ret));
return ret;
}
vector<int> guess(int n) {
vector <int> ans(n);
// if (n <= 15) {
// for (int i = 0; i < n; i++) {
// ans[i] = ask(i+1);
// }
// return ans;
// }
first = ask(1);
ans[0] = first;
vector<int> av(n-1);
for (int i = 1; i < n; i++) {
av[i-1] = i;
}
vector<int> tot = getNums(av);
vector<vector<int>> on(7);
vector<vector<int>> off(7, vector<int>(n));
for (int i = 0; i < 7; i++) {
vector<int> prep;
for (int j = 0; j < n; j++) {
if ((1<<i)&j) {
prep.push_back(j);
}
}
if (prep.size() != 0) {
on[i] = getNums(prep);
}
off[i].resize(set_difference(all(tot), all(on[i]), off[i].begin())-off[i].begin());
}
for (int i = 1; i < n; i++) {
vector<int> cur(tot.size());
copy(all(tot), cur.begin());
for (int b = 0; b < 7; b++) {
vector<int>& nxt = (((1<<b)&i) ? on[b] : off[b]);
cur.resize(set_intersection(all(cur), all(nxt), cur.begin())-cur.begin());
}
assert(cur.size() == 1);
ans[i] = cur[0];
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Xoractive.cpp: In function 'std::vector<int> getNums(std::vector<int>)':
Xoractive.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
Xoractive.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i = 1; i < res.size(); i++) {
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |