QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#336667 | #2199. Intriguing Selection | Milan | WA | 1ms | 3600kb | C++23 | 1.5kb | 2024-02-24 19:01:16 | 2024-02-24 19:01:17 |
Judging History
answer
#include <bits/stdc++.h>
#define MULTI int _; cin >> _; while(_--)
#define fi first
#define se second
#define pb(a) push_back(a)
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n, m) for(int i = n; i <= m; i++)
#define repsv(i, n, m) for(int i = n; i >= m; i--)
#define vsz(a) (int)(a.size())
#define mp(a, b) make_pair(a, b)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
#ifdef LOCAL
#include "debugs.hpp"
#else
#define dbg(...) 0
#endif
int n;
vi a;
bool ask(int x, int y){
cout << "? " << x << ' ' << y << '\n';
char in;
cin >> in;
return in == '<';
}
int cmp(int l, int r){
if(l==r) return a[l];
else{
int m = (l+r)/2;
int v1 = cmp(l, m);
int v2 = cmp(m+1, r);
if(v1 != -1) swap(v1, v2);
if(v1 == -1 && v2 == -1)
return -1;
if(v1 == -1)
return v2;
if(ask(v1, v2))
return v1;
else
return v2;
}
}
void solve(){
cin >> n;
n *= 2;
a = vi(n);
rep(i, n) a[i] = i+1;
random_device rd;
mt19937 g(rd());
shuffle(all(a),g);
rep(i, n/2){
int noob = cmp(0, n-1);
a[noob-1] = -1;
}
cout << "!\n";
}
int main(){
ios_base::sync_with_stdio(false);
MULTI
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3600kb
input:
2 3 > > > < > > > > > > > > > 3 < > > > < > > > < > > > <
output:
? 5 6 ? 4 6 ? 1 2 ? 3 2 ? 3 6 ? 5 6 ? 4 6 ? 1 2 ? 2 6 ? 5 6 ? 4 6 ? 1 2 ? 2 6 ! ? 5 3 ? 6 5 ? 2 1 ? 4 1 ? 1 5 ? 6 5 ? 2 1 ? 4 1 ? 1 5 ? 6 5 ? 2 1 ? 4 1 ? 1 5 !
result:
wrong answer Case 0: the top n are not uniquely determined: 4 is not compared to 1