为什么会RE呢?
查看原帖
为什么会RE呢?
215953
wzch楼主2024/7/22 22:01

不太会玩这个交互库。


#include<bits/stdc++.h>
using namespace std;
#define For(i, l, r) for(int i=(l);i<=(r);++i)
#define Rfor(i, r, l) for(int i=(r);i>=(l);--i)
#define O(x) cerr<<(#x)<<":"<<(x)<<endl
#define OO(x,y) cerr<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<endl
#define OOO(x,y,z) cerr<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<endl
#define OOOO(x,y,z,f) cerr<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#f)<<":"<<f<<endl
#define FENGE cerr<<"----------------------------------------------------------"<<endl
#define LO(a, l, r) {For(supervariable, l, r)cerr<<a[supervariable]<<" ";cerr<<"\n";}
#define FS(v,V,u,fa) for(int v:V[(u)])if(v!=(fa))
int read(){int x=0,t=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')t=-t;ch=getchar();}while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();return x*t;}
const int N=1005;
int n;
struct cmp {
	bool operator()(const int &a,const int &b) const 
	{
		printf("? %d %d\n",a, b);fflush(stdout);
		return read();
	}
};
set<int, cmp> S;
int main()
{
	int n=read();
	For(i, 1, n)S.insert(i);
	For(i, 1, n-1)
	{
		auto x=S.begin(),y=prev(S.end());
		printf("+ %d %d\n", *x, *y);fflush(stdout);
		S.erase(x);S.erase(y);S.insert(read());
	}
	printf("!\n");fflush(stdout);
}

2024/7/22 22:01
加载中...