답안 #857587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857587 2023-10-06T12:33:34 Z TAhmed33 아름다운 순열 (IZhO12_beauty) C++
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
bool ok[20][20];
long long dp[20][1<<20];
int arr[20],n;
int get1(int x) {
int cnt=0;
while (x){
cnt+=(x%3==1);
x/=3;
}
return cnt;
}
int get1(int x) {
return __builtin_popcount(x);
}
int ans (int pos, int mask) {
int &ret=dp[pos][mask];
if (ret !=-1) return ret;
if(mask==0) return ret=1;
ret=0;
for (int j=0;j<n;j++){
if ((mask&(1<<j))&&ok[pos][j]) ret+=ans(j,mask^(1<<j));
}
return ret;
}
int main () {
memset(dp,-1,sizeof(dp));
cin>>n;
for(int i=0;i<n;i++)cin>>arr[i];
for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
if(get1(i)==get1(j)||get2(i)==get2(j)) {
ok[i][j]=ok[j][i]=1;
}
}
long long sum=0;
for(int i=0;i<n;i++)sum+=ans(i,(1<<i)-1-(1<<i));
cout<<sum;
}

Compilation message

beauty.cpp:14:5: error: redefinition of 'int get1(int)'
   14 | int get1(int x) {
      |     ^~~~
beauty.cpp:6:5: note: 'int get1(int)' previously defined here
    6 | int get1(int x) {
      |     ^~~~
beauty.cpp: In function 'int ans(int, int)':
beauty.cpp:18:22: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   18 | int &ret=dp[pos][mask];
      |          ~~~~~~~~~~~~^
beauty.cpp: In function 'int main()':
beauty.cpp:32:22: error: 'get2' was not declared in this scope; did you mean 'get1'?
   32 | if(get1(i)==get1(j)||get2(i)==get2(j)) {
      |                      ^~~~
      |                      get1