답안 #97561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97561 2019-02-17T03:52:34 Z shoemakerjo Broken Device (JOI17_broken_device) C++14
100 / 100
64 ms 3328 KB
#include "Annalib.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool marked[200];

void Anna( int N, ll X, int K, int P[] ){
	for (int i = 0; i < N; i++) marked[i] = false;

	for (int i = 0; i < K; i++) {
		marked[P[i]] = true;
	}

	int a, b, c;
	for (int i = 0; i < N; i += 3) {
		a = i; b = i+1; c = i+2;
		int ct = 0;
		if (marked[a]) ct++;
		if (marked[b]) ct++;
		if (marked[c]) ct++;
		if (ct >= 2) {
			Set(a, 0); Set(b, 0); Set(c, 0);
			continue;
		}
		if (ct == 0) {
			//set all to 1 for a 1 bit

			if (X % 4 == 0) {
				Set(a, 0); Set(b, 1); Set(c, 1);
			}
			if (X % 4 == 2) {
				Set(a, 0); Set(b, 1); Set(c, 0);
			}	
			if (X % 4 == 1) {
				Set(a, 1); Set(b, 0); Set(c, 1);
			}
			if (X % 4 == 3) {
				Set(a, 1); Set(b, 1); Set(c, 1);
			}
			X /= 4;

		}
		if (ct == 1) {
			if (X % 2 == 0) {
				if (marked[a]) {
					if (X % 4 == 0) {
						Set(a, 0); Set(b, 1); Set(c, 1);
					}
					else {
						Set(a, 0); Set(b, 1); Set(c, 0);
					}
					X/=4;
				}
				else {
					Set(a, 1); Set(b, 0); Set(c, 0);
					X /= 2;
				}
			}
			else {
				if (marked[c]) {
					Set(a, 1); Set(b, 1); Set(c, 0);
				}
				else {
					Set(a, 0); Set(b, 0); Set(c, 1);
				}
				X /= 2;
			}

		}
	}

}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;
#define ll long long

ll Bruno( int N, int A[] ){
	ll res = 0;
	for (int i = N-1; i > 0; i -= 3) {
		int a = i-2;
		int b = i-1;
		int c = i;

		if (A[a] == 0 && A[b] == 0 && A[c] == 0) continue;

		int cv = (A[c] == 1) + 2*(A[b] == 1) + 4*(A[a] == 1);

		// cout << "cv : " << cv << endl;

		if (cv == 1) {
			res = res * 2 + 1;
		}
		if (cv == 2) {
			res = res * 4 + 2;
		}
		if (cv == 3) {
			res = res * 4 + 0;
		}
		if (cv == 4) {
			res = res * 2 + 0;
		}
		if (cv == 5) {
			res = res * 4 + 1;
		}
		if (cv == 6) {
			res = res * 2 + 1;
		}
		if (cv == 7) {
			res = res * 4 + 3;
		}
	}
	// cout << "RES: "  <<  res << endl;
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 3072 KB Output is correct - L* = 40
2 Correct 49 ms 3056 KB Output is correct - L* = 40
3 Correct 63 ms 3056 KB Output is correct - L* = 40
4 Correct 43 ms 3000 KB Output is correct - L* = 40
5 Correct 51 ms 3056 KB Output is correct - L* = 40
6 Correct 44 ms 3056 KB Output is correct - L* = 40
7 Correct 50 ms 3056 KB Output is correct - L* = 40
8 Correct 41 ms 3072 KB Output is correct - L* = 40
9 Correct 52 ms 3056 KB Output is correct - L* = 40
10 Correct 53 ms 3072 KB Output is correct - L* = 40
11 Correct 40 ms 3072 KB Output is correct - L* = 40
12 Correct 48 ms 3056 KB Output is correct - L* = 40
13 Correct 54 ms 3008 KB Output is correct - L* = 40
14 Correct 61 ms 3056 KB Output is correct - L* = 40
15 Correct 51 ms 3056 KB Output is correct - L* = 40
16 Correct 51 ms 3064 KB Output is correct - L* = 40
17 Correct 56 ms 3064 KB Output is correct - L* = 40
18 Correct 43 ms 3072 KB Output is correct - L* = 40
19 Correct 56 ms 3256 KB Output is correct - L* = 40
20 Correct 57 ms 3056 KB Output is correct - L* = 40
21 Correct 49 ms 3056 KB Output is correct - L* = 40
22 Correct 47 ms 3224 KB Output is correct - L* = 40
23 Correct 60 ms 3120 KB Output is correct - L* = 40
24 Correct 50 ms 3056 KB Output is correct - L* = 40
25 Correct 48 ms 3056 KB Output is correct - L* = 40
26 Correct 56 ms 3056 KB Output is correct - L* = 40
27 Correct 56 ms 3000 KB Output is correct - L* = 40
28 Correct 60 ms 3056 KB Output is correct - L* = 40
29 Correct 60 ms 3312 KB Output is correct - L* = 40
30 Correct 37 ms 3072 KB Output is correct - L* = 40
31 Correct 52 ms 3056 KB Output is correct - L* = 40
32 Correct 50 ms 3056 KB Output is correct - L* = 40
33 Correct 53 ms 3072 KB Output is correct - L* = 40
34 Correct 64 ms 3056 KB Output is correct - L* = 40
35 Correct 45 ms 3232 KB Output is correct - L* = 40
36 Correct 50 ms 3056 KB Output is correct - L* = 40
37 Correct 45 ms 3056 KB Output is correct - L* = 40
38 Correct 56 ms 3328 KB Output is correct - L* = 40
39 Correct 38 ms 3072 KB Output is correct - L* = 40
40 Correct 53 ms 2824 KB Output is correct - L* = 40