제출 #217341

#제출 시각아이디문제언어결과실행 시간메모리
217341SortingXoractive (IZhO19_xoractive)C++14
100 / 100
7 ms512 KiB
#include <bits/stdc++.h> #include "interactive.h" using namespace std; const int kBits = 7; map<int, bool> mp[kBits]; vector<int> guess(int n) { vector <int> ans(n); ans[0] = ask(1); for(int i = 0; i < 7; ++i){ vector<int> v; for(int j = 2; j <= n; ++j){ if((1 << i) & j) v.push_back(j); } if(v.empty()) continue; vector<int> pairs_without = get_pairwise_xor(v); pairs_without.insert(pairs_without.begin(), 0); v.push_back(1); vector<int> pairs_with = get_pairwise_xor(v); for(int idx_with = 0, idx_without = 0; idx_with < pairs_with.size(); ++idx_with){ if(idx_without < pairs_without.size() && pairs_with[idx_with] == pairs_without[idx_without]) ++idx_without; else mp[i][pairs_with[idx_with]] = true; } } for(int i = 2; i <= n; ++i){ int first_bit = 0; for(; first_bit < kBits; ++first_bit) if((1 << first_bit) & i) break; ans[i - 1] = -1; for(auto p: mp[first_bit]){ int x = p.first; bool ok = true; for(int bit = 0; bit < kBits; ++bit){ if(bit == first_bit) continue; if((1 << bit) & i){ if(!mp[bit].count(x)){ ok = false; break; } } else{ if(mp[bit].count(x)){ ok = false; break; } } } if(ok){ ans[i - 1] = x ^ ans[0]; break; } } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:29:51: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int idx_with = 0, idx_without = 0; idx_with < pairs_with.size(); ++idx_with){
                                          ~~~~~~~~~^~~~~~~~~~~~~~~~~~~
Xoractive.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(idx_without < pairs_without.size() && pairs_with[idx_with] == pairs_without[idx_without])
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...