답안 #1040694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040694 2024-08-01T08:31:45 Z 우민규(#10996) How to Avoid Disqualification in 75 Easy Steps (CEOI23_avoid) C++17
9.99998 / 100
2 ms 348 KB
#include "avoid.h"
#include <bits/stdc++.h>
using namespace std;

const int n = 1000;

void my_send(function<bool(int)> f) {
  vector<int> to_send;
  for (int i = 0; i < n; ++i) {
    if (f(i)) to_send.push_back(i + 1);
  }
  send(to_send);
}

std::pair<int, int> scout(int R, int H) {
  for (int bit = 0; bit < 10; ++bit) {
    my_send([&](int x) { return (x & (1 << bit)) == 0; });
  }
  for (int bit = 0; bit < 10; ++bit) {
    my_send([&](int x) { return (x & (1 << bit)) != 0; });
  }
  for (int fst_bit = 0; fst_bit < 10; ++fst_bit) {
    for (int snd_bit = fst_bit + 1; snd_bit < 10; ++snd_bit) {
      my_send([&](int x) { return ((x >> fst_bit) & 1) == ((x >> snd_bit) & 1); });
    }
  }
  auto p = wait();
  auto is_same = [&](int i, int j) {
    int idx = 20;
    for (int fst_bit = 0; fst_bit < 10; ++fst_bit) {
      for (int snd_bit = fst_bit + 1; snd_bit < 10; ++snd_bit) {
        if (fst_bit == i && snd_bit == j) break;
        idx += 1;
      }
      if (fst_bit == i) break;
    }
    return p[idx];
  };

  int anb = 0, aob = 0;
  int fst_diff = -1;
  for (int bit = 0; bit < 10; ++bit) {
    int has0 = p[bit], has1 = p[bit + 10];
    if (has1) aob |= 1 << bit;
    if (!has0) anb |= 1 << bit;
    if (has0 && has1) {
      if (fst_diff == -1) fst_diff = bit;
    }
  }
  
  if (fst_diff == -1) {
    // two are same
    return {anb + 1, anb + 1};
  }
  
  int a = anb, b = anb | (1 << fst_diff);
  for (int bit = 0; bit < 10; ++bit) {
    int has0 = p[bit], has1 = p[bit + 10];
    if (has0 && has1) {
      if (bit == fst_diff) continue;
      if (!is_same(fst_diff, bit)) {
        a |= 1 << bit;
      } else {
        b |= 1 << bit;
      }
    }
  }
  return {a + 1, b + 1};
}

#ifndef EVAL
#include "sample_grader.cpp"
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
2 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
3 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
4 Correct 2 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
5 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
6 Correct 2 ms 348 KB Correct: 65 robot(s) used, 1 hour(s) passed
7 Correct 2 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
8 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
9 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
10 Correct 2 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
11 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
12 Correct 2 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
13 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
14 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed
15 Correct 1 ms 344 KB Correct: 65 robot(s) used, 1 hour(s) passed