답안 #61192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61192 2018-07-25T10:36:10 Z ainta Broken Device (JOI17_broken_device) C++17
100 / 100
77 ms 3840 KB
#include "Annalib.h"

int v[200], res[220];

void Anna( int N, long long X, int K, int P[] ){
	int i, j, k;
	for (i = 0; i < N; i++)res[i] = v[i] = 0;
	for (i = 0; i < K; i++) {
		v[P[i]] = 1;
	}
	for (i = 0; i < N; i+=3) {
		if (v[i] + v[i + 1] + v[i+2] >= 2)continue;
		if (v[i] + v[i + 1] + v[i + 2] == 1) {
			if (X % 2 == 0) {
				if (v[i]) {
					res[i + 2] = 1;
				}
				if (v[i + 1]) {
					res[i + 2] = 1;
				}
				if (v[i + 2]) {
					res[i] = res[i + 1] = 1;
				}
			}
			else {
				if (v[i]) {
					if (X % 4 == 1) {
						res[i + 1] = 1;
					}
					else {
						res[i + 1] = res[i + 2] = 1;
					}
					X /= 2;
				}
				if (v[i + 1]) {
					res[i] = 1;
				}
				if (v[i + 2]) {
					res[i] = 1;
				}
			}
			X /= 2;
		}
		else {
			res[i] = res[i + 1] = res[i + 2] = 1;
			if (X % 4 == 1) res[i] = res[i + 2] = 0;
			if (X % 4 == 2) res[i + 1] = 0;
			if (X % 4 == 3) res[i] = 0;
			X /= 4;
		}
	}
	for (i = 0; i < N; i++)Set(i, res[i]);
}
#include "Brunolib.h"
#include <algorithm>
using namespace std;
#define pii pair<int,int>

pii Get(int x, int y, int z) {
	int t = x * 4 + y * 2 + z;
	if (t == 7)return pii(0,4);
	if (t == 6)return pii(0,2);
	if (t == 5)return pii(2,4);
	if (t == 4)return pii(1,2);
	if (t == 3)return pii(3,4);
	if (t == 2)return pii(1,4);
	if (t == 1)return pii(0,2);
	if (t == 0)return pii(0,1);
}

long long Bruno( int N, int A[] ){
	int i;
	long long res = 0;
	for (i = N-3; i >=0; i-=3) {
		pii tp = Get(A[i], A[i + 1], A[i + 2]);
		res = res*tp.second + tp.first;
	}
	return res;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:6:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, k;
         ^
Anna.cpp:6:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k;
            ^

Bruno.cpp: In function 'std::pair<int, int> Get(int, int, int)':
Bruno.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 3056 KB Output is correct - L* = 40
2 Correct 57 ms 3336 KB Output is correct - L* = 40
3 Correct 62 ms 3504 KB Output is correct - L* = 40
4 Correct 72 ms 3560 KB Output is correct - L* = 40
5 Correct 74 ms 3560 KB Output is correct - L* = 40
6 Correct 56 ms 3560 KB Output is correct - L* = 40
7 Correct 72 ms 3560 KB Output is correct - L* = 40
8 Correct 52 ms 3560 KB Output is correct - L* = 40
9 Correct 65 ms 3560 KB Output is correct - L* = 40
10 Correct 58 ms 3616 KB Output is correct - L* = 40
11 Correct 51 ms 3616 KB Output is correct - L* = 40
12 Correct 57 ms 3616 KB Output is correct - L* = 40
13 Correct 77 ms 3768 KB Output is correct - L* = 40
14 Correct 72 ms 3768 KB Output is correct - L* = 40
15 Correct 56 ms 3768 KB Output is correct - L* = 40
16 Correct 60 ms 3768 KB Output is correct - L* = 40
17 Correct 53 ms 3768 KB Output is correct - L* = 40
18 Correct 67 ms 3768 KB Output is correct - L* = 40
19 Correct 74 ms 3768 KB Output is correct - L* = 40
20 Correct 66 ms 3768 KB Output is correct - L* = 40
21 Correct 76 ms 3768 KB Output is correct - L* = 40
22 Correct 56 ms 3768 KB Output is correct - L* = 40
23 Correct 65 ms 3768 KB Output is correct - L* = 40
24 Correct 75 ms 3776 KB Output is correct - L* = 40
25 Correct 60 ms 3776 KB Output is correct - L* = 40
26 Correct 56 ms 3840 KB Output is correct - L* = 40
27 Correct 66 ms 3840 KB Output is correct - L* = 40
28 Correct 45 ms 3840 KB Output is correct - L* = 40
29 Correct 50 ms 3840 KB Output is correct - L* = 40
30 Correct 69 ms 3840 KB Output is correct - L* = 40
31 Correct 63 ms 3840 KB Output is correct - L* = 40
32 Correct 56 ms 3840 KB Output is correct - L* = 40
33 Correct 50 ms 3840 KB Output is correct - L* = 40
34 Correct 64 ms 3840 KB Output is correct - L* = 40
35 Correct 57 ms 3840 KB Output is correct - L* = 40
36 Correct 68 ms 3840 KB Output is correct - L* = 40
37 Correct 67 ms 3840 KB Output is correct - L* = 40
38 Correct 56 ms 3840 KB Output is correct - L* = 40
39 Correct 62 ms 3840 KB Output is correct - L* = 40
40 Correct 49 ms 3840 KB Output is correct - L* = 40