답안 #946241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946241 2024-03-14T12:56:02 Z Zena_Hossam 아름다운 순열 (IZhO12_beauty) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double
#define ll int
//#define ll1 long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
ll c=0,n;vector<vector<ll>>s;
void solve(ll uu,ll k,ll o){
    ll u=uu;u=(u|(1<<k));
    //cout<<k<<" ";
if(o==n-1){
    c++;return;
 
}
for(ll i=0;i<s[k].sz;i++){
 
    if((u&(1<<(s[k][i]))))continue;
    solve(v,s[k][i],o+1);
}return;
}
int main()
{
    //freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout);
    ll T=1;fi
    //cin>>T;ll oo=0;
    while(T--)
    {
       cin>>n;
       ll arr[n];s.resize(n+5);
       for(ll i=0;i<n;i++){
        cin>>arr[i];
       }ll m[n+5]={};ll d[n+5]={};
       for(ll i=0;i<n;i++){
            ll a=arr[i];ll p=0;
            while(a!=0){
                if(a%2==1)p++;
                a/=2;
            }
            m[i]=p;
            ll b=arr[i];ll pp=0;
            while(b!=0){
                if(b%3==1)pp++;
                b/=3;
            }
            d[i]=pp;
       }
       for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){if(i==j)continue;
            if(m[i]==m[j]){s[i].push_back(j);//cout<<i<<" "<<j<<"k\n";
            s[j].push_back(i);}
            else if(d[i]==d[j]){s[i].push_back(j);//cout<<i<<" "<<j<<"k\n";
            s[j].push_back(i); }
        }
       }vector<ll>r(n+9,0);
       for(ll i=0;i<n;i++){
       solve(r,i,0);//cout<<"\n";
       }cout<<c;
    }
}

Compilation message

beauty.cpp: In function 'void solve(int, int, int)':
beauty.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 | for(ll i=0;i<s[k].sz;i++){
      |             ^
beauty.cpp:23:11: error: 'v' was not declared in this scope
   23 |     solve(v,s[k][i],o+1);
      |           ^
beauty.cpp: In function 'int main()':
beauty.cpp:61:14: error: cannot convert 'std::vector<int>' to 'int'
   61 |        solve(r,i,0);//cout<<"\n";
      |              ^
      |              |
      |              std::vector<int>
beauty.cpp:13:15: note:   initializing argument 1 of 'void solve(int, int, int)'
   13 | void solve(ll uu,ll k,ll o){
      |               ^