답안 #494269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494269 2021-12-15T00:55:25 Z flappybird Minerals (JOI19_minerals) C++14
70 / 100
53 ms 4296 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n'
#define MAX 101010

ll rnd[MAX];
vector<ll> A, B; //A is old
ll chk[MAX];
ll rem[MAX];
ll pv = 0;
ll pvv = 0;

ll query(ll x) {
	rem[x] = !rem[x];
	pv = pvv;
	pvv = Query(rnd[x]);
	return pvv;
}

void answer(ll x, ll y) {
	Answer(rnd[x], rnd[y]);
}

void rnd_gen(ll N) {
	ll i;
	for (i = 1; i <= 2 * N; i++) rnd[i] = i;
	for (i = 2 * N; i > 1; i--) {
		ll a = rand() % i + 1;
		swap(rnd[i], rnd[a]);
	}
}

ll ans[MAX];

void Solve(int N) {
	srand(77777); //lucky seven
	ll i;
	rnd_gen(N);
	for (i = 1; i <= 2 * N; i++) {
		ll res = query(i);
		if (res != pv) {
			B.push_back(i);
			chk[i] = 1;
		}
		else {
			A.push_back(i);
			chk[i] = 0;
		}
	}
	for (i = 1; i <= 2 * N; i++) rem[i] = 1;
	ll b;
	for (b = 15; b >= 0; b--) {
		for (i = 0; i < N; i++) {
			if (!((1LL << b) & i)) {
				if (!rem[B[i]]) query(B[i]);
			}
			else {
				if (rem[B[i]]) query(B[i]);
			}
		}
		for (i = 0; i < N; i++) if (query(A[i]) != pv) ans[i] += (1LL << b);
	}
	for (i = 0; i < N; i++) answer(A[i], B[ans[i]]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
4 Correct 6 ms 1096 KB Output is correct
5 Correct 13 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
19 Incorrect 40 ms 4056 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
19 Incorrect 40 ms 4056 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
19 Incorrect 40 ms 4056 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
19 Incorrect 40 ms 4056 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 13 ms 1864 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 8 ms 1480 KB Output is correct
12 Correct 15 ms 1868 KB Output is correct
13 Correct 18 ms 1868 KB Output is correct
14 Correct 18 ms 1820 KB Output is correct
15 Correct 39 ms 4296 KB Output is correct
16 Correct 53 ms 4276 KB Output is correct
17 Correct 39 ms 4272 KB Output is correct
18 Correct 36 ms 4156 KB Output is correct
19 Incorrect 40 ms 4056 KB Wrong Answer [2]
20 Halted 0 ms 0 KB -