제출 #629624

#제출 시각아이디문제언어결과실행 시간메모리
629624abeker죄수들의 도전 (IOI22_prison)C++17
65 / 100
12 ms1160 KiB
#include <bits/stdc++.h>
#include "prison.h"
using namespace std;

int get_bit(int x, int i) {
  return x >> i & 1;
}

int cmp(int a, int b) {
  if (a == b)
    return -1;
  return a > b;
}

vector <vector <int>> devise_strategy(int N) {
  int lg = 0;
  while (1 << lg + 1 <= N)
    lg++;
  vector <vector <int>> strat(2 * lg + 1, vector <int> (N + 1));
  for (int i = 0; i <= 2 * lg; i++) {
    int group = (i + 1) / 2;
    strat[i][0] = group % 2;
    for (int j = 1; j <= N; j++) {
      int tmp = cmp(get_bit(j, lg - group + 1), i % 2);
      if (tmp == -1 && group == lg)
        tmp = j % 2;
      if (tmp == -1)
        strat[i][j] = 2 * group + 2 - get_bit(j, lg - group);
      else
        strat[i][j] = -(tmp ^ strat[i][0]) - 1;
    }
  }
  return strat;
}

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:17:18: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   17 |   while (1 << lg + 1 <= N)
      |               ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...