Submission #708216

# Submission time Handle Problem Language Result Execution time Memory
708216 2023-03-11T10:23:59 Z happypotato None (JOI16_memory2) C++17
0 / 100
1 ms 340 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
int buff[101][101];
int ans[101];
int ask(int x, int y) {
	if (buff[x][y] != -1) return buff[x][y];
	return buff[x][y] = Flip(x, y);
}
int add(vector<int> &v) {
	int mini = 100;
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j < 4; j++) {
			mini = min(mini, ask(v[i], v[j]));
		}
	}
	for (int i = 0; i < 4; i++) {
		int cnt = 0;
		for (int j = 0; j < 4; j++) {
			if (i == j) continue;
			cnt += (ask(v[i], v[j]) == mini);
		}
		if (cnt == 3) {
			ans[v[i]] = mini;
			return i;
		}
	}
	return -1;
}
void Solve(int T, int n){
	for (int i = 0; i < 2 * n; i++) {
		for (int j = 0; j < 2 * n; j++) {
			buff[i][j] = -1;
		}
	}
	vector<int> v = {0, 1, 2, 3};
	for (int i = 4; i < 2 * n; i++) {
		v[add(v)] = i;
	}
	int rem = add(v);
	vector<int> left;
	for (int i = 0; i < 4; i++) {
		if (i != rem) left.push_back(v[i]);
	}
	vector<int> queries;
	queries.push_back(ask(left[0], left[1]));
	queries.push_back(ask(left[0], left[2]));
	queries.push_back(ask(left[1], left[2]));
	if (queries[0] == queries[1]) {
		ans[left[1]] = ans[left[2]] = queries[2];
		ans[left[0]] = queries[0];
	} else if (queries[0] == queries[2]) {
		ans[left[0]] = ans[left[2]] = queries[1];
		ans[left[1]] = queries[0];
	} else if (queries[1] == queries[2]) {
		ans[left[0]] = ans[left[1]] = queries[0];
		ans[left[2]] = queries[1];
	}
	cout << endl;
	for (int i = 0; i < n; i++) {
		pair<int, int> res = {-1, -1};
		for (int j = 0; j < 2 * n; j++) {
			if (ans[j] == i) {
				if (res.first == -1) res.first = j;
				else res.second = j;
			}
		}
		Answer(res.first, res.second, i);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -