Submission #983447

# Submission time Handle Problem Language Result Execution time Memory
983447 2024-05-15T12:53:42 Z AmirAli_H1 Broken Device (JOI17_broken_device) C++17
100 / 100
33 ms 3004 KB
// In the name of Allah

#include <bits/stdc++.h>
#include "Annalib.h"
using namespace std;

typedef		long long int			ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;
typedef		complex<ld>				cld;

#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		F						first
#define		S						second
#define		pb						push_back
#define		sep						' '
#define		endl					'\n'
#define		Mp						make_pair
#define		kill(x)					cout << x << '\n', exit(0)
#define		set_dec(x)				cout << fixed << setprecision(x);
#define		file_io(x,y)			freopen(x, "r", stdin); freopen(y, "w", stdout);

static int n, k; ll x;
static const int maxn = 150 + 4;
static const int maxlg = 60;
static int A[maxn], M[maxn];

void Anna(int nx, ll valx, int kx, int p[]) {
	n = nx; k = kx; x = valx;
	
	iota(A, A + n, 0); fill(M, M + n, 0);
	for (int i = 0; i < k; i++) M[p[i]] = 1;
	shuffle(A, A + n, default_random_engine(23232323));
	
	for (int i = 1; i < n; i += 2) {
		int j1 = A[i - 1], j2 = A[i];
		if (x % 3 == 0) {
			if (M[j1]) {
				Set(j1, 0); Set(j2, 0);
			}
			else {
				Set(j1, 1); Set(j2, 0);
				x /= 3;
			}
		}
		else if (x % 3 == 1) {
			if (M[j2]) {
				Set(j1, 0); Set(j2, 0);
			}
			else {
				Set(j1, 0); Set(j2, 1);
				x /= 3;
			}
		}
		else {
			if (M[j1] || M[j2]) {
				Set(j1, 0); Set(j2, 0);
			}
			else {
				Set(j1, 1); Set(j2, 1);
				x /= 3;
			}
		}
	}
	if (n % 2 == 1) Set(A[n - 1], 0);
}
// In the name of Allah

#include <bits/stdc++.h>
#include "Brunolib.h"
using namespace std;

typedef		long long int			ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;
typedef		complex<ld>				cld;

#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		F						first
#define		S						second
#define		pb						push_back
#define		sep						' '
#define		endl					'\n'
#define		Mp						make_pair
#define		kill(x)					cout << x << '\n', exit(0)
#define		set_dec(x)				cout << fixed << setprecision(x);
#define		file_io(x,y)			freopen(x, "r", stdin); freopen(y, "w", stdout);

static int n;
static const int maxn = 150 + 4;
static const int maxlg = 60;
static int A[maxn], val[maxn];

ll Bruno(int nx, int a[]) {
	n = nx; iota(A, A + n, 0);
	for (int i = 0; i < n; i++) val[i] = a[i];
	shuffle(A, A + n, default_random_engine(23232323));
	
	ll res = 0, p = 1;
	for (int i = 1; i < n; i += 2) {
		int j1 = A[i - 1], j2 = A[i];
		if (val[j1] == 1 && val[j2] == 1) {
			res += (p * 2); p *= 3;
		}
		else if (val[j1] == 0 && val[j2] == 1) {
			res += p; p *= 3;
		}
		else if (val[j1] == 1 && val[j2] == 0) {
			p *= 3;
		}
	}
	
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2372 KB Output is correct - L* = 40
2 Correct 28 ms 2400 KB Output is correct - L* = 40
3 Correct 27 ms 2448 KB Output is correct - L* = 40
4 Correct 27 ms 2460 KB Output is correct - L* = 40
5 Correct 28 ms 2484 KB Output is correct - L* = 40
6 Correct 29 ms 2492 KB Output is correct - L* = 40
7 Correct 27 ms 2396 KB Output is correct - L* = 40
8 Correct 31 ms 3004 KB Output is correct - L* = 40
9 Correct 28 ms 2396 KB Output is correct - L* = 40
10 Correct 28 ms 2392 KB Output is correct - L* = 40
11 Correct 28 ms 2396 KB Output is correct - L* = 40
12 Correct 27 ms 2500 KB Output is correct - L* = 40
13 Correct 28 ms 2524 KB Output is correct - L* = 40
14 Correct 30 ms 2472 KB Output is correct - L* = 40
15 Correct 31 ms 2420 KB Output is correct - L* = 40
16 Correct 28 ms 2376 KB Output is correct - L* = 40
17 Correct 28 ms 2396 KB Output is correct - L* = 40
18 Correct 27 ms 2500 KB Output is correct - L* = 40
19 Correct 27 ms 2488 KB Output is correct - L* = 40
20 Correct 27 ms 2396 KB Output is correct - L* = 40
21 Correct 27 ms 2548 KB Output is correct - L* = 40
22 Correct 32 ms 2608 KB Output is correct - L* = 40
23 Correct 28 ms 2396 KB Output is correct - L* = 40
24 Correct 28 ms 2388 KB Output is correct - L* = 40
25 Correct 28 ms 2440 KB Output is correct - L* = 40
26 Correct 29 ms 2488 KB Output is correct - L* = 40
27 Correct 33 ms 2440 KB Output is correct - L* = 40
28 Correct 30 ms 2400 KB Output is correct - L* = 40
29 Correct 28 ms 2368 KB Output is correct - L* = 40
30 Correct 29 ms 2396 KB Output is correct - L* = 40
31 Correct 27 ms 2396 KB Output is correct - L* = 40
32 Correct 28 ms 2372 KB Output is correct - L* = 40
33 Correct 32 ms 2400 KB Output is correct - L* = 40
34 Correct 32 ms 2628 KB Output is correct - L* = 40
35 Correct 28 ms 2444 KB Output is correct - L* = 40
36 Correct 28 ms 2452 KB Output is correct - L* = 40
37 Correct 30 ms 2304 KB Output is correct - L* = 40
38 Correct 28 ms 2396 KB Output is correct - L* = 40
39 Correct 31 ms 2304 KB Output is correct - L* = 40
40 Correct 28 ms 2372 KB Output is correct - L* = 40