QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623267 | #8239. Mysterious Tree | FXLY_awa# | WA | 1ms | 3592kb | C++20 | 3.3kb | 2024-10-09 10:59:35 | 2024-10-09 10:59:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define itn int
#define endl '\n'
#define Endl endl
#define ednl endl
#define al(a) (a).begin(),(a).end()
#define all(a) (a).begin()+1,(a).end()
#define debug(x) {cerr<<"ss:"<<x<<endl;}
#define qdebug(x) {cerr<<"ss:";for(auto i:x)cout<<i<<" ";cout<<endl;}
#define lowbit(x) (x&-x)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define fs first
#define sc second
constexpr long long maxlonglong = 9223372036854775807; //9e18
constexpr int maxint = 2147483647; //2e9
constexpr int INF = 0x7f7f7f7f7f7f7f7f; //2139062143^2
constexpr int M = 1e9 + 7;
constexpr int mod = 998244353;
constexpr int hs = 0x1F351F35; // good hash number.
const double pi = acos(-1.0);
const double eps = 1e-15;
vector<int> input(int n){vector<int> a(n+1);for(int i=1;i<=n;i++)cin>>a[i];return a;}
mt19937_64 rnd(time(0));
constexpr int N=1231564;
int ask(int u,int v){
int res;
cout<<"? "<<u<<" "<<v<<endl;
cout.flush();
cin>>res;
return res;
}
inline void solve(){
int n;cin>>n;
int t=0;
for(int i=1;i<=n/2;i++){
if(ask(i,n+1-i)){
t=i;
break;
}
}
if(!t&&n%2){
if(ask(1,(n+1)/2)){
t=(n+1)/2;
}
}
if(t==0){
cout<<"! "<<1<<endl;
}
else{
int u=t,v;
if(u==(n+1)/2)v=1;
else v=(n+1)-u;
for(int i=1;i<=n;i++)if(u!=i&&v!=i){
t=i;
break;
}
if(ask(u,t)){
int x;
for(int i=1;i<=n;i++)if(u!=i&&v!=i&&t!=i){
x=i;
break;
}
if(ask(u,x)){
cout<<"! "<<2<<endl;
}
else cout<<"! "<<1<<endl;
}
else if(ask(v,t)){
int x;
for(int i=1;i<=n;i++)if(u!=i&&v!=i&&t!=i){
x=i;
break;
}
if(ask(v,x)){
cout<<"! "<<2<<endl;
}
else cout<<"! "<<1<<endl;
}
else cout<<"! "<<1<<endl;
}
cout.flush();
}
signed main()
{
//freopen("E:\work tool\code document\data\input.in", "r", stdin);
//freopen("E:\work tool\code document\data\output.out", "w", stdout);
// ios::sync_with_stdio(false);
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0); //关闭同步 如果使用 则不要使用<cstdio>
cout << fixed << setprecision(20);
int T=1;
// cin>>T;
while(T--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3592kb
input:
2 4 1 1
output:
? 1 2 ? 1 2 ? 1 94650671044800 ! 2
result:
wrong answer format Expected int32, but "94650671044800" found (test case 1)