Submission #199766

# Submission time Handle Problem Language Result Execution time Memory
199766 2020-02-03T08:43:56 Z abra_stone None (JOI16_memory2) C++14
100 / 100
6 ms 504 KB
#include "Memory2_lib.h"
#include <vector>
#include <cstring>
#define N 55
using namespace std;

int me[N * 2][N * 2];
vector<int> ve[N];

int flip(int p, int q) {
	if (me[p][q] != -1) return me[p][q];
	return me[p][q] = me[q][p] = Flip(p, q);
}

int f(int p, int q0, int q1, int q2, int q3) {
	ve[p].clear();
	ve[p].push_back(q0);
	if (flip(q1, q2) == p) {
		if (flip(q1, q3) == p) {
			ve[p].push_back(q1);
			ve[flip(q2, q3)].push_back(q3);
			return q2;
		} else {
			ve[p].push_back(q2);
			ve[flip(q1, q3)].push_back(q3);
			return q1;
		}
	} else {
		ve[flip(q1, q2)].push_back(q2);
		ve[flip(q1, q3)].push_back(q3);
		return q1;
	}
}

void Solve(int T, int n) {
	int i, j, t;
	memset(me, -1, sizeof(me));
	for (i = 0, j = 1; j < 2 * n; j++) {
		t = flip(i, j);
		ve[t].push_back(j);
		if (ve[t].size() == 3) {
			i = f(t, i, ve[t][0], ve[t][1], ve[t][2]);
		}
	}
	for (j = 0; j < n; j++) {
		if (ve[j].size() == 1) ve[j].push_back(i);
		Answer(ve[j][0], ve[j][1], j);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct