QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#116854 | #6668. Trokuti | He_Ren# | 0 | 0ms | 0kb | C++17 | 1.8kb | 2023-06-30 09:22:08 | 2024-05-31 18:32:01 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded