답안 #231336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231336 2020-05-13T11:30:14 Z bensonlzl Broken Device (JOI17_broken_device) C++14
100 / 100
69 ms 3264 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[]){
	srand(1);
	vector<int> v;
	for (int i = 0; i < N; ++i){
		usable[i] = 1;
		ans[i] = 0;
		v.push_back(i);
	}
	random_shuffle(v.begin(),v.end());
	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[]){
	srand(1);
	ll ans = 0;
	vector<int> v;
	for (int i = 0; i < N; ++i){
		v.push_back(i);
	}
	random_shuffle(v.begin(),v.end());
	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 60 ms 3056 KB Output is correct - L* = 40
2 Correct 62 ms 3072 KB Output is correct - L* = 40
3 Correct 57 ms 3056 KB Output is correct - L* = 40
4 Correct 61 ms 3056 KB Output is correct - L* = 40
5 Correct 59 ms 3056 KB Output is correct - L* = 40
6 Correct 61 ms 3056 KB Output is correct - L* = 40
7 Correct 57 ms 3072 KB Output is correct - L* = 40
8 Correct 60 ms 3056 KB Output is correct - L* = 40
9 Correct 61 ms 3064 KB Output is correct - L* = 40
10 Correct 62 ms 3056 KB Output is correct - L* = 40
11 Correct 61 ms 3056 KB Output is correct - L* = 40
12 Correct 61 ms 3072 KB Output is correct - L* = 40
13 Correct 61 ms 3056 KB Output is correct - L* = 40
14 Correct 63 ms 3072 KB Output is correct - L* = 40
15 Correct 61 ms 3072 KB Output is correct - L* = 40
16 Correct 59 ms 2992 KB Output is correct - L* = 40
17 Correct 61 ms 3056 KB Output is correct - L* = 40
18 Correct 60 ms 3056 KB Output is correct - L* = 40
19 Correct 60 ms 3072 KB Output is correct - L* = 40
20 Correct 60 ms 3072 KB Output is correct - L* = 40
21 Correct 60 ms 3072 KB Output is correct - L* = 40
22 Correct 57 ms 3056 KB Output is correct - L* = 40
23 Correct 61 ms 3056 KB Output is correct - L* = 40
24 Correct 64 ms 3056 KB Output is correct - L* = 40
25 Correct 61 ms 3072 KB Output is correct - L* = 40
26 Correct 63 ms 3056 KB Output is correct - L* = 40
27 Correct 64 ms 3064 KB Output is correct - L* = 40
28 Correct 61 ms 3072 KB Output is correct - L* = 40
29 Correct 60 ms 3072 KB Output is correct - L* = 40
30 Correct 62 ms 3056 KB Output is correct - L* = 40
31 Correct 63 ms 3056 KB Output is correct - L* = 40
32 Correct 63 ms 3072 KB Output is correct - L* = 40
33 Correct 62 ms 3056 KB Output is correct - L* = 40
34 Correct 66 ms 3072 KB Output is correct - L* = 40
35 Correct 60 ms 3072 KB Output is correct - L* = 40
36 Correct 66 ms 3264 KB Output is correct - L* = 40
37 Correct 65 ms 3056 KB Output is correct - L* = 40
38 Correct 69 ms 3008 KB Output is correct - L* = 40
39 Correct 66 ms 3008 KB Output is correct - L* = 40
40 Correct 63 ms 3056 KB Output is correct - L* = 40