답안 #1010220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010220 2024-06-28T13:27:31 Z MilosMilutinovic Bitwise (BOI06_bitwise) C++14
25 / 100
3 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> k(p);
  for (int i = 0; i < p; i++) {
    cin >> k[i];
  }
  vector<int> from(n);
  vector<int> to(n);
  for (int i = 0; i < n; i++) {
    cin >> from[i] >> to[i];
  }
  auto Check = [&](int target) {
    int ptr = 0;
    for (int g = 0; g < p; g++) {
      int L = ptr, R = ptr + k[g];
      bool found = false;
      {
        int total = 0;
        for (int i = L; i < R; i++) {
          total |= (to[i]);
        }
        if ((total & target) == target) {
          found = true;
        }
      }
      for (int i = L; i < R; i++) {
        for (int b = 0; b < 30; b++) {
          if (to[i] >> b & 1) {
            int val = 0;
            for (int t = 0; t < 30; t++) {
              if (t == b) {
                continue;
              }
              if (t < b) {
                val += (1 << t);
              } else {
                if (to[i] >> t & 1) {
                  val += (1 << t);
                }
              }
            }
            int total = val;
            for (int j = L; j < R; j++) {
              if (i == j) {
                continue;
              }
              total |= to[j];
            }
            if ((total & target) == target) {
              found = true;
            }
          }
        }
      }
      if (!found) {
        return false;
      }
      ptr = R;
    }
    return true;
  };
  int res = 0;
  for (int b = 30; b >= 0; b--) {
    if (Check(res + (1 << b))) {
      res += (1 << b);
    }
  }
  cout << res << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 456 KB Output isn't correct
4 Incorrect 1 ms 452 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Correct 1 ms 348 KB Output is correct
13 Incorrect 2 ms 604 KB Output isn't correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Incorrect 3 ms 348 KB Output isn't correct
16 Correct 3 ms 348 KB Output is correct
17 Incorrect 1 ms 452 KB Output isn't correct
18 Incorrect 3 ms 348 KB Output isn't correct
19 Incorrect 3 ms 348 KB Output isn't correct
20 Incorrect 1 ms 464 KB Output isn't correct