| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 282444 | keta_tsimakuridze | 아름다운 순열 (IZhO12_beauty) | C++14 | 980 ms | 205556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long n,k,b,ones[2][25],cur,a[25],dp[2000005][25],ans;
main(){
cin>>n;
for(k=0;k<n;k++){
cin>>a[k];
b=a[k];
while(b){
if(b%2) ones[0][k]++;
b/=2;
}
b=a[k];
while(b){
if(b%3==1) ones[1][k]++;
b/=3;
}
dp[1<<k][k]=1;
}
for(k=1;k<(1<<n);k++){
for(int j=0;j<n;j++){
b=1ll<<j;
if(! (b&k)) continue;
cur=k^b;
for(int i=0;i<n;i++){
b=1ll<<i;
if(!(b&cur)) continue;
// cout<<k<<" "<<i<<" "<<j<<endl;
if(ones[0][j]==ones[0][i] || ones[1][j]==ones[1][i]){
dp[k][j]+=dp[cur][i];// cout<<cur<<" "<<i<<endl;
} }
// cout<<k<<"_"<<j<<" "<<dp[k][j]<<endl;
if(k == ((1<<n) -1)) ans+=dp[k][j];
} }
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
