답안 #1077698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077698 2024-08-27T08:38:30 Z coolboy19521 아름다운 순열 (IZhO12_beauty) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
#define ll long long

using namespace std;

const int sz = 22;

int vi[1ll << sz][sz];
ll dp[1ll << sz][sz];
int tw[sz], tr[sz];
int a[sz], n;
int pc;

bool matc(int i, int j) {
    if (tw[i] == tw[j] || tr[i] == tr[j])
        return true;
    return false;
}

ll go(int i, ll bt) {
    if (bt == (1ll << n) - 1) return 1ll;
    short& v = vi[bt][i];
    ll& r = dp[bt][i];
    if (v == pc) return r;
    v = pc, r = 0;
    for (int j = 0; j < n; j ++) {
        int f = bt & (1ll << j);
        if (!f && matc(i, j))
            r += go(j, bt | (1 << j));
    }
    return r;
}

signed main() {
    cin >> n;

    for (int i = 0; i < n; i ++)
        cin >> a[i];

    for (int i = 0; i < n; i ++) {
        for (int cn = a[i]; 0 < cn; cn /= 2)
            tw[i] += cn % 2;
        for (int cn = a[i]; 0 < cn; cn /= 3)
            tr[i] += 1 == cn % 3;
    }

    ll cn = 0;

    for (int i = 0; i < n; i ++) {
        pc ++;
        cn += go(i, 1ll << i);
    }

    cout << cn << '\n';
}

Compilation message

beauty.cpp: In function 'long long int go(int, long long int)':
beauty.cpp:22:24: error: cannot bind non-const lvalue reference of type 'short int&' to an rvalue of type 'short int'
   22 |     short& v = vi[bt][i];
      |                ~~~~~~~~^