QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#340341 | #6668. Trokuti | ivanj | 0 | 0ms | 4244kb | C++11 | 3.3kb | 2024-02-28 21:23:16 | 2024-02-28 21:23:17 |
answer
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int n = 100;
int mat[n][n];
vector<int> know;
map<vector<int>, int> G;
mt19937 rng(39465329);
int ask(int x, int y, int z) {
printf("? %d %d %d\n", x + 1, y + 1, z + 1);
fflush(stdout);
int ret;
scanf("%d", &ret);
return ret;
}
int idx(int x, int y) {
return x * 5 + y - (x + 1) * (x + 2) / 2;
}
void prep() {
for(int i = 0;i < (1 << 10);i++) {
vector<int> ans;
for(int a = 0;a < 5;a++)
for(int b = a + 1;b < 5;b++) {
vector<int> v;
for(int j = 0;j < 5;j++)
if(j != a && j != b) v.pb(j);
int cnt = 0;
int p1 = idx(v[0], v[1]);
int p2 = idx(v[0], v[2]);
int p3 = idx(v[1], v[2]);
cnt += (i & (1 << p1)) > 0;
cnt += (i & (1 << p2)) > 0;
cnt += (i & (1 << p3)) > 0;
ans.pb(cnt);
}
G[ans] = i;
}
}
void add(int x, vector<int> v) {
int m = v.size();
if(m == 0) return;
if(m == 1) {
if(know.size()) {
int y = know.back();
mat[x][v[0]] = mat[v[0]][x] = ask(x, y, v[0]) - mat[x][y] - mat[y][v[0]];
} else {
int y = 0, z = 1;
if(v[0] == 0) y = 1, z = 2;
if(v[0] == 1) z = 2;
int a = ask(x, y, z);
int b = ask(x, y, v[0]);
int c = ask(x, z, v[0]);
mat[x][v[0]] = mat[v[0]][x] = (b + c - a) / 2;
know.pb(v[0]);
}
return;
}
vector<int> new_v, idx;
for(int i = 1;i < m;i += 2) {
int cnt = ask(x, v[i - 1], v[i]) - mat[v[i - 1]][v[i]];
if(cnt == 0) {
know.pb(v[i]), know.pb(v[i - 1]);
mat[x][v[i]] = mat[v[i]][x] = 0;
mat[x][v[i - 1]] = mat[v[i - 1]][x] = 0;
}
if(cnt == 2) {
know.pb(v[i]), know.pb(v[i - 1]);
mat[x][v[i]] = mat[v[i]][x] = 1;
mat[x][v[i - 1]] = mat[v[i - 1]][x] = 1;
}
if(cnt == 1)
new_v.pb(v[i]), idx.pb(i);
}
add(x, new_v);
for(int i : idx) {
know.pb(v[i - 1]);
mat[x][v[i - 1]] = mat[v[i - 1]][x] = !mat[x][v[i]];
}
if(m & 1) {
int z = v.back();
int y = know.back();
mat[x][z] = mat[z][x] = ask(x, y, z) - mat[x][y] - mat[y][z];
}
}
void solve(int x, int a, int b, int c) {
int A = ask(x, a, b);
int B = ask(x, a, c);
int C = ask(x, b, c);
mat[x][a] = mat[a][x] = (A + B - C) / 2;
mat[x][b] = mat[b][x] = (A + C - B) / 2;
mat[x][c] = mat[c][x] = (B + C - A) / 2;
}
int main() {
prep();
vector<int> ans;
for(int i = 0;i < 5;i++)
for(int j = i + 1;j < 5;j++) {
vector<int> v;
for(int k = 0;k < 5;k++)
if(k != i && k != j) v.pb(k);
ans.pb(ask(v[0], v[1], v[2]));
}
int mask = G[ans];
for(int i = 0;i < 5;i++)
for(int j = i + 1;j < 5;j++)
if(mask & (1 << idx(i, j)))
mat[i][j] = mat[j][i] = 1;
for(int i = 5;i < n;i++) {
for(int j = 0;j + 2 < i;j += 3)
solve(i, j, j + 1, j + 2);
if(i % 3) {
mat[i][i - 1] = mat[i - 1][i] = ask(i, i - 1, 0) - mat[i - 1][0] - mat[i][0];
if(i % 3 == 2)
mat[i][i - 2] = mat[i - 2][i] = ask(i, i - 2, 0) - mat[i - 2][0] - mat[i][0], cout << i << "\n";
}
//vector<int> v;
//for(int j = 0;j < i;j++) v.pb(j);
//shuffle(all(v), rng);
//know.clear();
//add(i, v);
}
printf("!\n");
for(int i = 0;i < n;i++, printf("\n"))
for(int j = 0;j < n;j++) printf("%d", mat[i][j]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4244kb
input:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
? 3 4 5 ? 2 4 5 ? 2 3 5 ? 2 3 4 ? 1 4 5 ? 1 3 5 ? 1 3 4 ? 1 2 5 ? 1 2 4 ? 1 2 3 ? 6 1 2 ? 6 1 3 ? 6 2 3 ? 6 5 1 ? 6 4 1 5 ? 7 1 2
result:
wrong answer unknown token 5