QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657372#9484. Colored Complete Graphucup-team5319#WA 2ms6372kbC++142.0kb2024-10-19 14:39:122024-10-19 14:39:13

Judging History

This is the latest submission verdict.

  • [2024-10-19 14:39:13]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 6372kb
  • [2024-10-19 14:39:12]
  • Submitted

answer

//Linkwish's code
#include<bits/stdc++.h>
#define si inline
#define fi first
#define se second
using namespace std;
typedef long long ll;typedef __int128 li;typedef long double ld;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef const int ci;typedef const ll cl;ci iinf=1e9;cl linf=LLONG_MAX;
template<typename T>si bool gmax(T &x,const T y){if(x<y)return x=y,1;return 0;}
template<typename T>si bool gmin(T &x,const T y){if(y<x)return x=y,1;return 0;}

namespace LinkWish{

	ci N=50005;

	int n;
	bool col[N];
	vector<int> e[N],g[N];
	si void adde(int x,int y){
		e[x].push_back(y);
		e[y].push_back(x);
	}
	si void addg(int x,int y){
		g[x].push_back(y);
		g[y].push_back(x);
	}

	map<pii,bool> vis;

	si bool ask(int x,int y){
		if(vis.count(minmax(x,y)))return vis[minmax(x,y)];
		cout<<"? "<<x<<' '<<y<<endl;
		char res;cin>>res;
		return vis[minmax(x,y)]=(res=='R');
	}

	bool got[N];
	void dfsg(int x){
		got[x]=true;
		for(int to:g[x]){
			if(!got[to]){
				cout<<x<<' '<<to<<endl;
				dfsg(to);
			}
		}
	}
	void dfse(int x){
		got[x]=true;
		for(int to:e[x]){
			if(!got[to]){
				cout<<x<<' '<<to<<endl;
				dfse(to);
			}
		}
	}

	si void solve(){
		cin>>n;
		vector<int> p,q;
		for(int i=2;i<=n;i++){
			if(ask(1,i))q.push_back(i),addg(1,i);
			else p.push_back(i),adde(1,i);
		}
		auto i=p.begin(),j=q.begin();
		bool side=0;
		while(i!=p.end()&&j!=q.end()){
			if(side){
				for(;i!=p.end()&&ask(*i,*j);i++)addg(*i,*j);
				if(i==p.end()){
					cout<<"!\n";
					dfsg(1);
					break;
				}
			}
			else{
				for(;j!=q.end()&&!ask(*i,*j);j++)adde(*i,*j);
				if(j==q.end()){
					cout<<"!\n";
					dfse(1);
					break;
				}
			}
			side^=1;
		}
	}

	void mian(){
		solve();
	}
}

signed main(){
	#ifndef ONLINE_JUDGE
	// assert(freopen("in.in","r",stdin));
	// assert(freopen("out.out","w",stdout));
	// assert(freopen("out.err","w",stderr));
	#endif
	LinkWish::mian();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 5980kb

input:

3
B
R
B

output:

? 1 2
? 1 3
? 2 3
!
1 2
2 3

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 6372kb

input:

983
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
R
...

output:

? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 1 8
? 1 9
? 1 10
? 1 11
? 1 12
? 1 13
? 1 14
? 1 15
? 1 16
? 1 17
? 1 18
? 1 19
? 1 20
? 1 21
? 1 22
? 1 23
? 1 24
? 1 25
? 1 26
? 1 27
? 1 28
? 1 29
? 1 30
? 1 31
? 1 32
? 1 33
? 1 34
? 1 35
? 1 36
? 1 37
? 1 38
? 1 39
? 1 40
? 1 41
? 1 42
? 1 43
? 1 44
? 1 45
...

result:

ok AC

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 5960kb

input:

75
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R

output:

? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 1 8
? 1 9
? 1 10
? 1 11
? 1 12
? 1 13
? 1 14
? 1 15
? 1 16
? 1 17
? 1 18
? 1 19
? 1 20
? 1 21
? 1 22
? 1 23
? 1 24
? 1 25
? 1 26
? 1 27
? 1 28
? 1 29
? 1 30
? 1 31
? 1 32
? 1 33
? 1 34
? 1 35
? 1 36
? 1 37
? 1 38
? 1 39
? 1 40
? 1 41
? 1 42
? 1 43
? 1 44
? 1 45
...

result:

wrong answer invalid question