답안 #284540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284540 2020-08-27T15:30:10 Z rama_pang Broken Device (JOI17_broken_device) C++14
0 / 100
40 ms 3568 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; i += 3) {
    if (j >= 60) break;
    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 += 2;
      }
    }
  }  
  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] == 0) {
      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 Runtime error 26 ms 3312 KB Execution killed with signal 11
2 Runtime error 27 ms 3328 KB Execution killed with signal 11
3 Runtime error 26 ms 3312 KB Execution killed with signal 11
4 Runtime error 40 ms 3312 KB Execution killed with signal 11
5 Runtime error 29 ms 3312 KB Execution killed with signal 11
6 Runtime error 27 ms 3328 KB Execution killed with signal 11
7 Runtime error 28 ms 3328 KB Execution killed with signal 11
8 Runtime error 27 ms 3312 KB Execution killed with signal 11
9 Runtime error 28 ms 3328 KB Execution killed with signal 11
10 Runtime error 28 ms 3328 KB Execution killed with signal 11
11 Runtime error 26 ms 3328 KB Execution killed with signal 11
12 Runtime error 28 ms 3312 KB Execution killed with signal 11
13 Runtime error 30 ms 3336 KB Execution killed with signal 11
14 Runtime error 27 ms 3312 KB Execution killed with signal 11
15 Runtime error 27 ms 3312 KB Execution killed with signal 11
16 Runtime error 26 ms 3312 KB Execution killed with signal 11
17 Runtime error 26 ms 3328 KB Execution killed with signal 11
18 Runtime error 28 ms 3328 KB Execution killed with signal 11
19 Runtime error 25 ms 3312 KB Execution killed with signal 11
20 Runtime error 32 ms 3312 KB Execution killed with signal 11
21 Runtime error 29 ms 3328 KB Execution killed with signal 11
22 Runtime error 27 ms 3328 KB Execution killed with signal 11
23 Runtime error 25 ms 3312 KB Execution killed with signal 11
24 Runtime error 25 ms 3312 KB Execution killed with signal 11
25 Runtime error 27 ms 3312 KB Execution killed with signal 11
26 Runtime error 26 ms 3328 KB Execution killed with signal 11
27 Runtime error 26 ms 3328 KB Execution killed with signal 11
28 Runtime error 28 ms 3328 KB Execution killed with signal 11
29 Runtime error 28 ms 3312 KB Execution killed with signal 11
30 Runtime error 31 ms 3568 KB Execution killed with signal 11
31 Runtime error 31 ms 3328 KB Execution killed with signal 11
32 Runtime error 30 ms 3328 KB Execution killed with signal 11
33 Runtime error 26 ms 3312 KB Execution killed with signal 11
34 Runtime error 31 ms 3328 KB Execution killed with signal 11
35 Runtime error 32 ms 3328 KB Execution killed with signal 11
36 Runtime error 31 ms 3312 KB Execution killed with signal 11
37 Runtime error 26 ms 3328 KB Execution killed with signal 11
38 Runtime error 29 ms 3312 KB Execution killed with signal 11
39 Runtime error 28 ms 3328 KB Execution killed with signal 11
40 Runtime error 28 ms 3288 KB Execution killed with signal 11