답안 #261556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261556 2020-08-11T21:13:02 Z sckmd 아름다운 순열 (IZhO12_beauty) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
int a[25];
bool moze[25][25];

bool check(int x,int y)
{
  binx = __builtin_popcount(x);
  biny = __builtin_popcount(y);
  if(binx==biny)return true;
  int cntx = 0;
  while(x > 0)
  {
    cntx += (x%3==1);
    x /= 3;
  }
  while(y > 0)
  {
    cnty += (y%3==1);
    y /= 3;
  }
  return cntx==cnty;
}
typedef long long ll;
ll dp[(1<<20)][20];

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
      moze[i][j]=check(a[i],a[j]);
    }
  }
  for(int i = 0; i < n; i++)dp[0][i]=1LL;
  for(int mask = 0; mask < (1<<n); mask++)
  {
    for(int i = 0; i < n; i++)
    {
      if(!(mask&(1<<i)))continue;
      for(int j = 0; j < n; j++)
      {
        if(!(mask&(1<<j)))continue;
        if(!moze[i][j])continue;
        dp[mask][i] += dp[mask^(1<<i)][j];
      }
    }
  }
  ll ans = 0LL;
  for(int i = 0; i < n; i++)ans += dp[(1<<n)-1][i];
  cout << ans;
  return 0;
}

Compilation message

beauty.cpp: In function 'bool check(int, int)':
beauty.cpp:9:3: error: 'binx' was not declared in this scope
   binx = __builtin_popcount(x);
   ^~~~
beauty.cpp:9:3: note: suggested alternative: 'uint'
   binx = __builtin_popcount(x);
   ^~~~
   uint
beauty.cpp:10:3: error: 'biny' was not declared in this scope
   biny = __builtin_popcount(y);
   ^~~~
beauty.cpp:10:3: note: suggested alternative: 'uint'
   biny = __builtin_popcount(y);
   ^~~~
   uint
beauty.cpp:20:5: error: 'cnty' was not declared in this scope
     cnty += (y%3==1);
     ^~~~
beauty.cpp:20:5: note: suggested alternative: 'cntx'
     cnty += (y%3==1);
     ^~~~
     cntx
beauty.cpp:23:16: error: 'cnty' was not declared in this scope
   return cntx==cnty;
                ^~~~
beauty.cpp:23:16: note: suggested alternative: 'cntx'
   return cntx==cnty;
                ^~~~
                cntx