QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340340#6668. Trokutiivanj0 18ms4232kbC++113.3kb2024-02-28 21:20:582024-02-28 21:20:59

Judging History

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

  • [2024-02-28 21:20:59]
  • 评测
  • 测评结果:0
  • 用时:18ms
  • 内存:4232kb
  • [2024-02-28 21:20:58]
  • 提交

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 - 1) % 3)
				mat[i][i - 2] = mat[i - 2][i] = ask(i, i - 2, 0) - mat[i - 2][0] - mat[i][0];	
		}
		//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: 30
Acceptable Answer
time: 4ms
memory: 4004kb

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
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
...

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
? 7 1 2
? 7 1 3
? 7 2 3
? 7 4 5
? 7 4 6
? 7 5 6
? 8 1 2
? 8 1 3
? 8 2 3
? 8 4 5
? 8 4 6
? 8 5 6
? 8 7 1
? 9 1 2
? 9 1 3
? 9 2 3
? 9 4 5
? 9 4 6
? 9 5 6
? 9 8 1
? 9 7 1
? 10 1 2
? 1...

result:

points 0.30 points  0.30 correct 4950 queries

Test #2:

score: 30
Acceptable Answer
time: 7ms
memory: 4232kb

input:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3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
? 7 4 6
? 7 5 6
? 8 1 2
? 8 1 3
? 8 2 3
? 8 4 5
? 8 4 6
? 8 5 6
? 8 7 1
? 9 1 2
? 9 1 3
? 9 2 3
? 9 4 5
? 9 4 6
? 9 5 6
? 9 8 1
? 9 7 1
? 10 1 2
? 1...

result:

points 0.30 points  0.30 correct 4950 queries

Test #4:

score: 30
Acceptable Answer
time: 4ms
memory: 3940kb

input:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

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
? 7 1 2
? 7 1 3
? 7 2 3
? 7 4 5
? 7 4 6
? 7 5 6
? 8 1 2
? 8 1 3
? 8 2 3
? 8 4 5
? 8 4 6
? 8 5 6
? 8 7 1
? 9 1 2
? 9 1 3
? 9 2 3
? 9 4 5
? 9 4 6
? 9 5 6
? 9 8 1
? 9 7 1
? 10 1 2
? 1...

result:

points 0.30 points  0.30 correct 4950 queries

Test #5:

score: 30
Acceptable Answer
time: 18ms
memory: 3964kb

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
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? 8 4 5
? 8 4 6
? 8 5 6
? 8 7 1
? 9 1 2
? 9 1 3
? 9 2 3
? 9 4 5
? 9 4 6
? 9 5 6
? 9 8 1
? 9 7 1
? 10 1 2
? 1...

result:

points 0.30 points  0.30 correct 4950 queries

Test #7:

score: 0
Wrong Answer
time: 11ms
memory: 4232kb

input:

0
0
0
0
1
1
0
1
0
0
0
1
1
1
0
1
1
0
1
0
1
2
1
1
1
0
1
2
1
0
1
1
1
2
1
1
1
1
0
0
0
0
0
1
1
0
1
1
1
1
0
0
0
0
1
0
1
1
1
2
1
2
2
2
0
2
1
1
0
0
0
0
0
0
0
0
2
1
0
0
0
0
0
0
1
1
0
1
2
0
1
1
0
1
1
2
1
1
1
0
0
1
0
0
2
1
0
1
0
0
0
0
1
1
1
1
1
1
2
2
0
0
0
1
1
0
1
0
1
0
1
0
0
1
0
0
0
1
1
0
0
0
2
1
1
1
1
1
1
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 1 2
? 6 1 3
? 6 2 3
? 6 5 1
? 6 4 1
? 7 1 2
? 7 1 3
? 7 2 3
? 7 4 5
? 7 4 6
? 7 5 6
? 8 1 2
? 8 1 3
? 8 2 3
? 8 4 5
? 8 4 6
? 8 5 6
? 8 7 1
? 9 1 2
? 9 1 3
? 9 2 3
? 9 4 5
? 9 4 6
? 9 5 6
? 9 8 1
? 9 7 1
? 10 1 2
? 1...

result:

wrong answer Token parameter [name=ans_i] equals to "010110000100100000011000000100...1121111121111111112121111111121", doesn't correspond to pattern "[01]{100,100}"