QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116854#6668. TrokutiHe_Ren#0 0ms0kbC++171.8kb2023-06-30 09:22:082024-05-31 18:32:01

Judging History

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

  • [2024-05-31 18:32:01]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 09:22:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 100 + 5;

mt19937 gen(114514);

int ask(int x,int y,int z)
{
	printf("? %d %d %d\n",x,y,z);
	fflush(stdout);
	int res;
	scanf("%d",&res);
	return res;
}

int n;
int ans[MAXN][MAXN];
array<int,3> rt = {0,0,0};

void updans(int u,int v,int w)
{
	ans[u][v] = ans[v][u] = w;
}

int ask(int u,int v)
{
	int k = ask(u, v, rt[0]) - ans[u][rt[0]] - ans[v][rt[0]];
	updans(u, v, k);
	return k;
}

int main(void)
{
	scanf("%d",&n);
	
	memset(ans, -1, sizeof(ans));
	for(int i=1; i<=n; ++i)
		ans[i][i] = 0;
	
	vector<int> id(n);
	iota(id.begin(), id.end(), 1);
	shuffle(id.begin(), id.end(), gen);
	
	[&] (void)
	{
		for(int i=0; i<n; ++i)
		for(int j=0; j<i; ++j)
		for(int k=0; k<j; ++k)
		{
			int t = ask(id[i], id[j], id[k]);
			if(t == 0 || t == 3)
			{
				int cur = t / 3;
				updans(id[i], id[j], cur);
				updans(id[i], id[k], cur);
				updans(id[j], id[k], cur);
				rt = {id[i], id[j], id[k]};
				return;
			}
		}
	}();
	
	for(auto t: rt)
		id.erase(find(id.begin(), id.end(), t));
	
	for(auto t: id)
	{
		int x01 = ask(t, rt[0], rt[1]) - ans[rt[0]][rt[1]];
		int x02 = ask(t, rt[0], rt[2]) - ans[rt[0]][rt[2]];
		int x12 = ask(t, rt[1], rt[2]) - ans[rt[1]][rt[2]];
		
		[&] (void)
		{
			for(int i=0; i<=1; ++i)
			for(int j=0; j<=1; ++j) if(i + j == x01)
			for(int k=0; k<=1; ++k) if(i + k == x02 && j + k == x12)
			{
				updans(t, rt[0], i);
				updans(t, rt[1], j);
				updans(t, rt[2], k);
				return;
			}
		}();
	}
	
	for(auto u: id)
		for(auto v: id) if(u < v)
			ask(u, v);
	
	printf("!\n");
	for(int i=1; i<=n; ++i, printf("\n"))
		for(int j=1; j<=n; ++j)
			printf("%d",ans[i][j]);
	return 0;
}

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:


output:


result: