Submission #1009076

#TimeUsernameProblemLanguageResultExecution timeMemory
1009076makanhuliaCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
2037 ms6488 KiB
#include <bits/stdc++.h> using namespace std; # define int long long # define fir first # define sec second # define pb push_back # define endl "\n" const int cnst = 2e5+5; bool mutipletestcase = 0; bool debug = 0; vector<int> act; int ask(int x, int idx) { cout << "? " << idx << " " << x << endl; int a; if(!debug) cin >> a; else { a = 0; for(auto v: act) if(idx <= v && (v+(v^idx)) == x) a = 1; else if(idx > v && (v-(v^idx)) == x) a = 1; } return a; // return 1; } void solve() { int n; cin >> n; if(debug) { int k; cin >> k; for(int i = 1; i<=k; i++) { int a; cin >> a; act.pb(a); } // cerr << 50+(50^31) << " " << 50+(50^32) << endl; } pair<int, int> uniq = {1, 1}; for(int j1 = 1; j1<=n; j1++) { for(int j2 = 1; j2<=n; j2++) { map<int, int> mp; map<int, int> mp2; bool yes = 1; for(int k = 1; k<=n; k++) { int a; int b; if(j1 <= k) a = k+(k^j1); else a = k-(k^j1); if(j2 <= k) b = k+(k^j2); else b = k-(k^j2); a += 1000; b += 1000; // cerr << k << " " << a << " " << b << endl; mp[a]++; mp2[b]++; } for(int k = 1; k<=n; k++) { int a; int b; if(j1 <= k) a = k+(k^j1); else a = k-(k^j1); if(j2 <= k) b = k+(k^j2); else b = k-(k^j2); a += 1000; b += 1000; // cerr << k << " " << a << " " << b << endl; if(mp[a] > 1 && mp2[b] > 1) yes = 0; } if(yes) { cerr << j1 << " " << j2 << endl; uniq = {j1, j2}; } } } // cerr << uniq.fir << " " << uniq.sec << endl; vector<int> ans; for(int i = 1; i<=n; i++) { int a; int b; if(uniq.fir <= i) a = i+(i^uniq.fir); else a = i-(i^uniq.fir); if(uniq.sec <= i) b = i+(i^uniq.sec); else b = i-(i^uniq.sec); // cerr << i << " " << a << " " << b << endl; int c = ask(a, uniq.fir); int d = ask(b, uniq.sec); if(c && d) ans.pb(i); } cout << "! " << ans.size() << " "; for(auto v: ans) cout << v << " "; cout << endl; } signed main() { // ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; if(mutipletestcase) cin >> t; while(t--) solve(); }

Compilation message (stderr)

commuter_pass.cpp: In function 'void solve()':
commuter_pass.cpp:113:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  113 |   for(auto v: ans) cout << v << " "; cout << endl;
      |   ^~~
commuter_pass.cpp:113:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  113 |   for(auto v: ans) cout << v << " "; cout << endl;
      |                                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...