답안 #231342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231342 2020-05-13T11:31:15 Z bensonlzl Broken Device (JOI17_broken_device) C++14
100 / 100
77 ms 3336 KB
#include <bits/stdc++.h>
#include "Annalib.h"

using namespace std;

typedef long long ll;

int usable[155], ans[155];

void Anna(int N, long long X, int K, int P[]){
	mt19937 rng(8537293);
	vector<int> v;
	for (int i = 0; i < N; ++i){
		usable[i] = 1;
		ans[i] = 0;
		v.push_back(i);
	}
	shuffle(v.begin(),v.end(),rng);
	for (int i = 0; i < K; ++i){
		usable[P[i]] = 0;
	}
	for (int i = 0; i < N; i += 2){
		if (usable[v[i]] && usable[v[i+1]]){
			if (X%3 == 0){
				ans[v[i]] = 0;
				ans[v[i+1]] = 1;
			}
			else if (X%3 == 1){
				ans[v[i]] = 1;
				ans[v[i+1]] = 0;
			}
			else{
				ans[v[i]] = 1;
				ans[v[i+1]] = 1;
			} 
			X /= 3;
		}
		else if (usable[v[i]] && !usable[v[i+1]] && (X%3 == 1)){
			ans[v[i]] = 1;
			ans[v[i+1]] = 0;
			X /= 3;
		}
		else if (!usable[v[i]] && usable[v[i+1]] && (X%3 == 0)){
			ans[v[i]] = 1;
			ans[v[i+1]] = 1;
			X /= 3;
		}
		else{
			ans[v[i]] = ans[v[i+1]] = 0;
		}
	}
	for (int i = 0; i < N; ++i){
		Set(i,ans[i]);
	}
}
#include <bits/stdc++.h>
#include "Annalib.h"

using namespace std;

typedef long long ll;

long long Bruno(int N, int A[]){
	mt19937 rng(8537293);
	ll ans = 0;
	vector<int> v;
	for (int i = 0; i < N; ++i){
		v.push_back(i);
	}
	shuffle(v.begin(),v.end(),rng);
	ll coeff = 1;
	for (int i = 0; i < N; i += 2){
		if (A[v[i]] || A[v[i+1]]){
			if (A[v[i]] && !A[v[i+1]]){
				ans += 1*coeff;
			}
			else if (A[v[i]] && A[v[i+1]]){
				ans += 2*coeff;
			}
			coeff *= 3;
			if (coeff > 1e18) break;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 3312 KB Output is correct - L* = 40
2 Correct 71 ms 3312 KB Output is correct - L* = 40
3 Correct 67 ms 3312 KB Output is correct - L* = 40
4 Correct 64 ms 3312 KB Output is correct - L* = 40
5 Correct 67 ms 3312 KB Output is correct - L* = 40
6 Correct 74 ms 3312 KB Output is correct - L* = 40
7 Correct 71 ms 3312 KB Output is correct - L* = 40
8 Correct 77 ms 3312 KB Output is correct - L* = 40
9 Correct 77 ms 3312 KB Output is correct - L* = 40
10 Correct 66 ms 3312 KB Output is correct - L* = 40
11 Correct 64 ms 3312 KB Output is correct - L* = 40
12 Correct 72 ms 3336 KB Output is correct - L* = 40
13 Correct 75 ms 3312 KB Output is correct - L* = 40
14 Correct 65 ms 3312 KB Output is correct - L* = 40
15 Correct 66 ms 3312 KB Output is correct - L* = 40
16 Correct 66 ms 3312 KB Output is correct - L* = 40
17 Correct 69 ms 3312 KB Output is correct - L* = 40
18 Correct 66 ms 3152 KB Output is correct - L* = 40
19 Correct 77 ms 3328 KB Output is correct - L* = 40
20 Correct 65 ms 3312 KB Output is correct - L* = 40
21 Correct 65 ms 3312 KB Output is correct - L* = 40
22 Correct 66 ms 3312 KB Output is correct - L* = 40
23 Correct 63 ms 3312 KB Output is correct - L* = 40
24 Correct 66 ms 3312 KB Output is correct - L* = 40
25 Correct 71 ms 3312 KB Output is correct - L* = 40
26 Correct 76 ms 3288 KB Output is correct - L* = 40
27 Correct 66 ms 3320 KB Output is correct - L* = 40
28 Correct 76 ms 3312 KB Output is correct - L* = 40
29 Correct 64 ms 3328 KB Output is correct - L* = 40
30 Correct 64 ms 3312 KB Output is correct - L* = 40
31 Correct 73 ms 3152 KB Output is correct - L* = 40
32 Correct 77 ms 3320 KB Output is correct - L* = 40
33 Correct 69 ms 3312 KB Output is correct - L* = 40
34 Correct 65 ms 3312 KB Output is correct - L* = 40
35 Correct 64 ms 3312 KB Output is correct - L* = 40
36 Correct 74 ms 3312 KB Output is correct - L* = 40
37 Correct 63 ms 3312 KB Output is correct - L* = 40
38 Correct 64 ms 3312 KB Output is correct - L* = 40
39 Correct 64 ms 3312 KB Output is correct - L* = 40
40 Correct 65 ms 3312 KB Output is correct - L* = 40