QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#349836#8057. Best Carry Player 4mcpqndqRE 0ms0kbC++171.8kb2024-03-10 06:23:572024-03-10 06:23:57

Judging History

你现在查看的是最新测评结果

  • [2024-03-10 06:23:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-10 06:23:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	int tests;cin>>tests;
	while(tests--){
		vi d(2501,0);
		vector<vi> to(2501);
		vector<vi> known(2501);
		
		map<pii,int> rev; // {a,b} in index rev[{a,b}] in a
		set<pii> edges;

		function<int(int)> solve = [&](int x){
			assert(d[x]>0);
			rep(i,1,d[x]+1){
				if(to[x][i]!=0) continue;
				cout<<"> "<<i<<endl;
				int y,dy;cin>>y>>dy;
				to[x][i]=y;
				rev[{x,y}]=i;
				edges.insert(minmax(x,y));
				known[x].pb(y);
				if(d[y]==0){
					d[y]=dy;
					to[y].assign(dy+1, 0);
				}
				return solve(y);
			}
			return x;
		};

		vi src(2501);
		vi vis(2501,-1);
		int time = 0;
		function<int(int)> find = [&](int loc){
			time++;
			if(sz(known[loc])<d[loc]) return loc;
			queue<int> q; q.push(loc);
			while(sz(q)){
				int cur = q.front(); q.pop();
				if(sz(known[cur])<d[cur]){
					vi path;
					while(cur!=loc) {
						path.pb(cur);
						cur=src[cur];
					}
					reverse(all(path));
					rep(i,0,sz(path)){
						cout<<"> "<<rev[{loc,path[i]}]<<endl;
						int w,dw;cin>>w>>dw;
						loc=path[i];
						assert(loc==w);
					}	
					return loc;
				}
				for(int con : known[cur]){
					if(vis[con]==time) continue;
					q.push(con);
					vis[con]=time;
					src[con]=cur;
				}
			}
			return 0;
		};
		
		int loc,dloc;cin>>loc>>dloc;
		d[loc]=dloc;
		to[loc].assign(dloc+1,0);
		while((loc=find(loc))!=0) loc=solve(loc);
		cout<<"!";
		for(pii p : edges)cout<<' '<<p.F<<' '<<p.S;
		cout<<endl;
		string res;cin>>res;
		assert(res=="Correct");
	}
}

详细

Test #1:

score: 0
Runtime Error

input:

5
2
1 2
3 4
3
1 0 1
0 1 0
4
1 0 0 1
1 1 1 1
5
123456 114514 1919810 233333 234567
20050815 998244353 0 0 0
10
5 3 5 3 2 4 2 4 1 5
9 9 8 2 4 4 3 5 3 0

output:

> 1
! 2 2

result: