제출 #782019

#제출 시각아이디문제언어결과실행 시간메모리
782019ymmMemory 2 (JOI16_memory2)C++17
100 / 100
1 ms308 KiB
#include "Memory2_lib.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 128;
int a[N], b[N];

int query(int i, int j)
{
	if (a[i] != -1)
		return a[i];
	if (a[j] != -1)
		return a[j];
	return Flip(i, j);
}

void Do(int i, int n)
{
	int cnt[N] = {};
	int val = 0;
	memset(b, -1, sizeof(b));
	Loop (j,0,2*n) {
		if (i == j)
			continue;
		int x = query(i, j);
		b[j] = x;
		val ^= x;
		if (++cnt[x] > 2) {
			val = x;
			break;
		}
	}
	Loop (j,0,2*n) {
		if (b[j] != -1 && b[j] != val)
			a[j] = b[j];
	}
	a[i] = val;
}

void Solve(int, int n)
{
	memset(a, -1, sizeof(a));
	Loop (i,0,2*n) {
		if (a[i] == -1)
			Do(i, n);
	}
	Loop (i,0,2*n) Loop (j,i+1,2*n) {
		if (a[i] == a[j])
			Answer(i, j, a[i]);
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...