Submission #782019

# Submission time Handle Problem Language Result Execution time Memory
782019 2023-07-13T14:47:48 Z ymm None (JOI16_memory2) C++17
100 / 100
1 ms 308 KB
#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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 252 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct