답안 #284732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284732 2020-08-27T23:45:03 Z rama_pang Broken Device (JOI17_broken_device) C++14
100 / 100
52 ms 3584 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna(int N, long long X, int K, int P[]) {
  vector<int> broken(N);
  for (int i = 0; i < K; i++) {
    broken[P[i]] = 1;
  }
  vector<int> bits;
  for (int i = 0; i < 61; i++) {
    bits.emplace_back(!!(X & (1ll << i)));
  }
  // 100 -> "0"
  // 001 -> "1"
  // 110 -> "1"
  // 010 -> "00"
  // 011 -> "01"
  // 101 -> "10"
  // 111 -> "11"
  vector<int> ans(N);
  for (int i = 0, j = 0; i < N && j < 60; i += 3) {
    int cnt = broken[i] + broken[i + 1] + broken[i + 2];
    if (cnt == 0) {
      if (bits[j] == 0 && bits[j + 1] == 0) {
        ans[i] = 0; ans[i + 1] = 1; ans[i + 2] = 0;
      } else if (bits[j] == 0 && bits[j + 1] == 1) {
        ans[i] = 0; ans[i + 1] = 1; ans[i + 2] = 1;
      } else if (bits[j] == 1 && bits[j + 1] == 0) {
        ans[i] = 1; ans[i + 1] = 0; ans[i + 2] = 1;
      } else if (bits[j] == 1 && bits[j + 1] == 1) {
        ans[i] = 1; ans[i + 1] = 1; ans[i + 2] = 1;
      }
      j += 2;
    } else if (cnt == 1) {
      if (bits[j] == 0) {
        if (!broken[i]) {
          ans[i] = 1; ans[i + 1] = 0; ans[i + 2] = 0;
          j += 1;
        } else {
          if (bits[j + 1] == 0) {
            ans[i] = 0; ans[i + 1] = 1; ans[i + 2] = 0;
          } else if (bits[j + 1] == 1) {
            ans[i] = 0; ans[i + 1] = 1; ans[i + 2] = 1;
          }
          j += 2;
        }
      } else if (bits[j] == 1) {
        if (!broken[i + 2]) {
          ans[i] = 0; ans[i + 1] = 0; ans[i + 2] = 1;
        } else {
          ans[i] = 1; ans[i + 1] = 1; ans[i + 2] = 0;
        }
        j += 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    Set(i, ans[i]);
  }
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

long long Bruno(int N, int A[]) {
  // 100 -> "0"
  // 001 -> "1"
  // 110 -> "1"
  // 010 -> "00"
  // 011 -> "01"
  // 101 -> "10"
  // 111 -> "11"
  vector<int> bits;
  for (int i = 0; i < N; i += 3) {
    if (A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 0) {
      bits.emplace_back(0);
    } else if (A[i] == 0 && A[i + 1] == 0 && A[i + 2] == 1) {
      bits.emplace_back(1);
    } else if (A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 0) {
      bits.emplace_back(1);
    } else if (A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 0) {
      bits.emplace_back(0);
      bits.emplace_back(0);
    } else if (A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 1) {
      bits.emplace_back(0);
      bits.emplace_back(1);
    } else if (A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 1) {
      bits.emplace_back(1);
      bits.emplace_back(0);
    } else if (A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 1) {
      bits.emplace_back(1);
      bits.emplace_back(1);
    }
  }
  long long ans = 0;
  for (int i = 0; i < 60; i++) {
    if (bits[i]) {
      ans |= 1ll << i;
    }
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 3328 KB Output is correct - L* = 40
2 Correct 47 ms 3328 KB Output is correct - L* = 40
3 Correct 46 ms 3312 KB Output is correct - L* = 40
4 Correct 45 ms 3328 KB Output is correct - L* = 40
5 Correct 47 ms 3568 KB Output is correct - L* = 40
6 Correct 47 ms 3312 KB Output is correct - L* = 40
7 Correct 45 ms 3312 KB Output is correct - L* = 40
8 Correct 47 ms 3584 KB Output is correct - L* = 40
9 Correct 50 ms 3312 KB Output is correct - L* = 40
10 Correct 46 ms 3312 KB Output is correct - L* = 40
11 Correct 46 ms 3328 KB Output is correct - L* = 40
12 Correct 46 ms 3328 KB Output is correct - L* = 40
13 Correct 46 ms 3312 KB Output is correct - L* = 40
14 Correct 46 ms 3312 KB Output is correct - L* = 40
15 Correct 50 ms 3328 KB Output is correct - L* = 40
16 Correct 51 ms 3312 KB Output is correct - L* = 40
17 Correct 50 ms 3312 KB Output is correct - L* = 40
18 Correct 46 ms 3328 KB Output is correct - L* = 40
19 Correct 47 ms 3312 KB Output is correct - L* = 40
20 Correct 46 ms 3328 KB Output is correct - L* = 40
21 Correct 46 ms 3328 KB Output is correct - L* = 40
22 Correct 46 ms 3120 KB Output is correct - L* = 40
23 Correct 46 ms 3328 KB Output is correct - L* = 40
24 Correct 46 ms 3312 KB Output is correct - L* = 40
25 Correct 47 ms 3312 KB Output is correct - L* = 40
26 Correct 46 ms 3312 KB Output is correct - L* = 40
27 Correct 46 ms 3328 KB Output is correct - L* = 40
28 Correct 46 ms 3136 KB Output is correct - L* = 40
29 Correct 46 ms 3328 KB Output is correct - L* = 40
30 Correct 45 ms 3312 KB Output is correct - L* = 40
31 Correct 46 ms 3312 KB Output is correct - L* = 40
32 Correct 46 ms 3584 KB Output is correct - L* = 40
33 Correct 46 ms 3328 KB Output is correct - L* = 40
34 Correct 46 ms 3312 KB Output is correct - L* = 40
35 Correct 45 ms 3328 KB Output is correct - L* = 40
36 Correct 48 ms 3328 KB Output is correct - L* = 40
37 Correct 46 ms 3240 KB Output is correct - L* = 40
38 Correct 45 ms 3312 KB Output is correct - L* = 40
39 Correct 45 ms 3312 KB Output is correct - L* = 40
40 Correct 52 ms 3328 KB Output is correct - L* = 40