답안 #70395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70395 2018-08-22T19:14:54 Z Just_Solve_The_Problem Broken Device (JOI17_broken_device) C++11
100 / 100
59 ms 3960 KB
#include <bits/stdc++.h>
#include "Annalib.h"
//#include "grader.cpp"

#define pb push_back

using namespace std;

void Anna( int N, long long X, int K, int P[] ){
  vector < int > used(N, 0);
  vector < int > u(N, 0);
  for (int i = 0; i < K; i++) {
    used[P[i]] = 1;
  }
  for (int i = 0; i < N; i += 3) {
    if (used[i] + used[i + 1] + used[i + 2] >= 2) continue;
    if (used[i] + used[i + 1] + used[i + 2] == 1) {
      if (X % 2 == 0) {
        if (used[i]) {
          u[i + 2] = 1;
        } else if (used[i + 1]) {
          u[i + 2] = 1;
        } else {
          u[i] = u[i + 1] = 1;
        }
      } else {
        if (used[i]) {
          if (X % 4 == 1) {
            u[i + 1] = 1;
          } else {
            u[i + 1] = u[i + 2] = 1;
          }
          X /= 2;
        }
        if (used[i + 1]) {
          u[i] = 1;
        }
        if (used[i + 2]) {
          u[i] = 1;
        }
      }
      X /= 2;
    } else {
      u[i] = u[i + 1] = u[i + 2] = 1;
      if (X % 4 == 1) u[i] = u[i + 2] = 0;
      else if (X % 4 == 2) u[i + 1] = 0;
      else if (X % 4 == 3) u[i] = 0;
      X /= 4;
    }
  }
  for (int i = 0; i < N; i++) {
    Set(i, u[i]);
  }
}
/*
7 = (3, 4)
6 = (2, 4)
5 = (1, 4)
4 = (0, 4)
3 = (1, 2)
2 = (0, 2)
1 = (0, 2)
0 = (1, 2)
*/
#include <bits/stdc++.h>
#include "Brunolib.h"
//#include "grader.cpp"

#define ll long long
#define pb push_back

using namespace std;

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

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

Compilation message

Bruno.cpp: In function 'std::pair<int, int> get(int, int, int)':
Bruno.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 3056 KB Output is correct - L* = 40
2 Correct 53 ms 3208 KB Output is correct - L* = 40
3 Correct 48 ms 3208 KB Output is correct - L* = 40
4 Correct 46 ms 3688 KB Output is correct - L* = 40
5 Correct 50 ms 3688 KB Output is correct - L* = 40
6 Correct 45 ms 3688 KB Output is correct - L* = 40
7 Correct 41 ms 3688 KB Output is correct - L* = 40
8 Correct 41 ms 3688 KB Output is correct - L* = 40
9 Correct 41 ms 3688 KB Output is correct - L* = 40
10 Correct 44 ms 3688 KB Output is correct - L* = 40
11 Correct 41 ms 3744 KB Output is correct - L* = 40
12 Correct 44 ms 3744 KB Output is correct - L* = 40
13 Correct 41 ms 3744 KB Output is correct - L* = 40
14 Correct 43 ms 3744 KB Output is correct - L* = 40
15 Correct 40 ms 3744 KB Output is correct - L* = 40
16 Correct 56 ms 3744 KB Output is correct - L* = 40
17 Correct 45 ms 3744 KB Output is correct - L* = 40
18 Correct 44 ms 3744 KB Output is correct - L* = 40
19 Correct 53 ms 3744 KB Output is correct - L* = 40
20 Correct 51 ms 3744 KB Output is correct - L* = 40
21 Correct 43 ms 3744 KB Output is correct - L* = 40
22 Correct 45 ms 3744 KB Output is correct - L* = 40
23 Correct 51 ms 3744 KB Output is correct - L* = 40
24 Correct 46 ms 3744 KB Output is correct - L* = 40
25 Correct 48 ms 3744 KB Output is correct - L* = 40
26 Correct 48 ms 3744 KB Output is correct - L* = 40
27 Correct 55 ms 3768 KB Output is correct - L* = 40
28 Correct 50 ms 3784 KB Output is correct - L* = 40
29 Correct 59 ms 3784 KB Output is correct - L* = 40
30 Correct 44 ms 3784 KB Output is correct - L* = 40
31 Correct 45 ms 3784 KB Output is correct - L* = 40
32 Correct 45 ms 3784 KB Output is correct - L* = 40
33 Correct 43 ms 3784 KB Output is correct - L* = 40
34 Correct 43 ms 3784 KB Output is correct - L* = 40
35 Correct 47 ms 3784 KB Output is correct - L* = 40
36 Correct 58 ms 3784 KB Output is correct - L* = 40
37 Correct 44 ms 3960 KB Output is correct - L* = 40
38 Correct 49 ms 3960 KB Output is correct - L* = 40
39 Correct 41 ms 3960 KB Output is correct - L* = 40
40 Correct 44 ms 3960 KB Output is correct - L* = 40