이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "interactive.h"
using namespace std;
int ask(int x);
vector <int> get_pairwise_xor(vector<int> v);
vector<int> guess(int n) {
vector <int> ans , q , aux , aux2;
set <int> ok[10] , s;
int p1 , bit , i , j , taken;
p1 = ask(1);
ans.push_back(p1);
for (bit = 0 ; bit <= 7 ; bit++){
q.clear();
for (i = 2 ; i <= n ; i++){
if ((i & (1 << bit)) == 0){
q.push_back(i);
}
}
aux = get_pairwise_xor(q);
q.push_back(1);
aux2 = get_pairwise_xor(q);
i = j = 0;
while (i < aux.size() && j < aux2.size()){
if (aux[i] == aux2[j]){
i++;
j++;
}
else {
if (aux2[j] != 0){
ok[bit].insert(aux2[j] ^ p1);
}
j++;
}
}
while (j < aux2.size()){
if (aux2[j] != 0){
ok[bit].insert(aux2[j] ^ p1);
}
j++;
}
}
for (i = 2 ; i <= n ; i++){
s.clear();
taken = 0;
for (bit = 0 ; bit <= 7 ; bit++){
if ( (i & (1 << bit)) == 0 ){
/// valoarea din i trb sa se regaseasca in ok[bit]
if (!taken){
for (set <int> :: iterator it = ok[bit].begin() ; it != ok[bit].end() ; it++)
s.insert(*it);
}
else {
aux.clear();
for (set <int> :: iterator it = s.begin() ; it != s.end() ; it++){
if (ok[bit].find(*it) != ok[bit].end())
aux.push_back(*it);
}
s.clear();
for (j = 0 ; j < aux.size() ; j++)
s.insert(aux[j]);
}
taken = 1;
}
}
/// -------------------------------------------------------------------------
for (bit = 0 ; bit <= 7 ; bit++){
if ( (i & (1 << bit))){
/// valoarea din i NU trb sa se regaseasca in ok[bit]
aux.clear();
for (set <int> :: iterator it = s.begin() ; it != s.end() ; it++){
if (ok[bit].find(*it) == ok[bit].end())
aux.push_back(*it);
}
s.clear();
for (j = 0 ; j < aux.size() ; j++)
s.insert(aux[j]);
}
}
if (s.size() == 1){
ans.push_back(*s.begin());
//printf ("%d %d\n" , s.size() , *s.begin());
}
else {
ans.push_back(ask(i));
//printf ("%d %d\n" , s.size() , *s.begin());
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | while (i < aux.size() && j < aux2.size()){
| ~~^~~~~~~~~~~~
Xoractive.cpp:33:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | while (i < aux.size() && j < aux2.size()){
| ~~^~~~~~~~~~~~~
Xoractive.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | while (j < aux2.size()){
| ~~^~~~~~~~~~~~~
Xoractive.cpp:84:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | for (j = 0 ; j < aux.size() ; j++)
| ~~^~~~~~~~~~~~
Xoractive.cpp:113:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
113 | for (j = 0 ; j < aux.size() ; j++)
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |