Submission #261557

# Submission time Handle Problem Language Result Execution time Memory
261557 2020-08-11T21:13:21 Z sckmd Beautiful row (IZhO12_beauty) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

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

bool check(int x,int y)
{
  int binx = __builtin_popcount(x);
  int 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: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