Submission #896694

#TimeUsernameProblemLanguageResultExecution timeMemory
896694vgtcrossXoractive (IZhO19_xoractive)C++17
100 / 100
3 ms596 KiB
#include <bits/stdc++.h> #define MODE 0 #if MODE #define debug(x) cout << #x << ": " << (x) << endl #define log(x) cout << (x) << endl #define test(x) x #else #define debug(x) #define log(x) #define test(x) #endif #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define fi first #define se second #define X real() #define Y imag() using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using P = complex<ll>; template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;} template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;} const ll M = 1000000007; // 998244353 int ask(int i) #if MODE == 0 ; #else { cout << "ask " << i << endl; int v; cin >> v; return v; } #endif vector<int> get_pairwise_xor(vector<int> pos) #if MODE == 0 ; #else { cout << "xor "; for (int i : pos) cout << i << ' '; cout << endl; vector<int> v(pos.size() * pos.size()); for (int &i : v) cin >> i; return v; } #endif vector<int> diff(vector<int> &a, vector<int> &b) { sort(all(a)); sort(all(b)); vector<int> c; int j = 0; for (int i = 0; i < a.size(); ++i) { if (j < b.size() && a[i] == b[j]) ++j; else c.push_back(a[i]); } return c; } vector<int> guess(int n) { int x = ask(n); map<int, int> mp; for (int i = 1; i < n; i *= 2) { vector<int> v; for (int j = 1; j < n; ++j) if (j & i) v.push_back(j); auto a = get_pairwise_xor(v); v.push_back(n); auto b = get_pairwise_xor(v); auto c = diff(b, a); for (int j = 1; j < c.size(); j += 2) mp[c[j] ^ x] += i; } vector<int> ans(n); ans[n-1] = x; for (pii p : mp) ans[p.se-1] = p.fi; return ans; } #if MODE int main() { cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; auto ans = guess(n); for (int i : ans) cout << i << ' '; cout << endl; return 0; } #endif

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> diff(std::vector<int>&, std::vector<int>&)':
Xoractive.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0; i < a.size(); ++i) {
      |                     ~~^~~~~~~~~~
Xoractive.cpp:68:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         if (j < b.size() && a[i] == b[j]) ++j;
      |             ~~^~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:84:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for (int j = 1; j < c.size(); j += 2) mp[c[j] ^ x] += i;
      |                         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...