제출 #1073701

#제출 시각아이디문제언어결과실행 시간메모리
1073701fv3죄수들의 도전 (IOI22_prison)C++17
0 / 100
0 ms348 KiB
#include "prison.h"
#include <bits/stdc++.h>
 
using namespace std;
 
vector<vector<int>> devise_strategy(int N) 
{
  vector<vector<int>> p(13 * 2 - 1, vector<int>(N+1, 1));
  int bit = 12;
  
  p[0][0] = 0;
  for (int j = 1; j <= N; j++)
  {
    if (j & (1 << bit))
      p[0][j] = 1;
    else
      p[0][j] = 2;
  }
 
  for (int i = 1; i < 13 * 2 - 1; i++)
  {
    bool A = ((i - 1) / 2) % 2;
    if (A)
      p[i][0] = 0;
 
    if (i % 2)
    {
      bit--;
      for (int j = 1; j <= N; j++)
      {
        if (j & (1 << (bit + 1)))
          p[i][j] = A ? -1 : -2;
        else if (j & (1 << (bit + 1)))
          p[i][j] = i + 2;
        else
          p[i][j] = i + 3;
      }
    }
    else
    {
      for (int j = 1; j <= N; j++)
      {
        if (j & (1 << (bit + 1)) == 0)
          p[i][j] = A ? -2 : -1;
        else if (j & (1 << bit))
          p[i][j] = i + 2;
        else
          p[i][j] = i + 1;
      }
    }
  }
 
  for (auto&n : p[24])
  {
    if (n == 25) n = -1;
    else n = -2;
  }
  for (auto&n : p[23])
  {
    if (n == 25) n = -1;
    else n = -2;
  }
  p[23][0] = 0;
  p[24][0] = 0;
 
  return p;
}

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

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:43:34: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   43 |         if (j & (1 << (bit + 1)) == 0)
      |                 ~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...