QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#340315 | #6668. Trokuti | ivanj | 0 | 7ms | 4260kb | C++11 | 2.8kb | 2024-02-28 20:59:56 | 2024-02-28 20:59:56 |
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]);
}
}
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] = 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) {
assert(know.size());
int y = know.back();
mat[x][v.back()] = mat[v.back()][x] = ask(x, v.back(), y) - mat[x][y] - mat[y][v.back()];
}
}
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++) {
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: 100
Accepted
time: 3ms
memory: 3976kb
input:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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8 7 ? 9 1 3 ? 9 4 2 ? 9 6 5 ? 9 6 2 ? 9 2 6 ? 10 4 1 ? 10 7 9 ? 10 5 2 ? 10 8 3 ? 10 6 8 ? 11 8 2 ? 11 1...
result:
points 1.0 points 1.0 correct 3375 queries
Test #9:
score: 0
Wrong Answer
time: 6ms
memory: 4036kb
input:
2 0 1 1 2 3 3 2 2 2 1 2 2 1 2 3 2 1 3 0 1 2 2 2 1 3 2 1 3 3 0 2 2 2 1 3 2 1 1 2 1 2 0 2 3 2 3 3 1 3 0 0 3 2 3 3 0 1 0 3 0 3 2 3 1 2 0 2 1 2 3 3 3 2 1 2 2 2 1 2 2 1 0 1 3 2 1 1 1 2 0 2 0 2 3 2 2 3 0 3 0 0 3 0 0 0 1 2 3 3 0 0 1 0 0 0 3 1 3 2 1 0 3 0 2 2 2 2 2 2 0 2 0 3 0 1 1 3 3 2 3 3 2 0 2 0 1 1 3 2 ...
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 3 2 ? 6 4 1 ? 6 2 1 ? 6 2 3 ? 6 2 1 ? 6 3 1 ? 6 1 1 ? 6 5 4 ? 7 3 1 ? 7 6 2 ? 7 5 4 ? 7 3 4 ? 7 4 3 ? 8 2 1 ? 8 7 6 ? 8 5 3 ? 8 1 6 ? 8 4 7 ? 9 8 7 ? 9 1 3 ? 9 4 2 ? 9 6 5 ? 10 4 1 ? 10 7 9 ? 10 5 2 ? 10 8 3 ? 10 1 2...
result:
wrong answer Token parameter [name=ans_i] equals to "011110111111111111111111111111...1111111111110111111111101111111", doesn't correspond to pattern "[01]{100,100}"