結果
| 問題 |
No.753 最強王者決定戦
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2018-03-04 13:25:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 1,000 ms |
| コード長 | 1,264 bytes |
| コンパイル時間 | 492 ms |
| コンパイル使用メモリ | 63,912 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 06:44:12 |
| 合計ジャッジ時間 | 2,055 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:64:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
64 | scanf("%d",&data[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
int data[17][17];
const int LIMIT=16;
long long int dp[17][16];
int isV(int p1,int p2){
if(p1>p2){
std::swap(p1,p2);
}
if(data[p1][p2]==1)return p1;
return p2;
}
void f(int p,std::vector<int>& all,std::vector<int>& Ls,std::vector<int>& Rs){
int s=all.size();
int s2=s/2;
if((s==2)||(s==Ls.size()+Rs.size())){
if(s==2){
dp[s][isV(all[0],all[1])]+=2;
}else{
int x=s/2;
for(int j=0;j<LIMIT;j++){
dp[x][j]=0;
}
std::vector<int> Ls2,Rs2;
f(0,Ls,Ls2,Rs2);
f(0,Rs,Ls2,Rs2);
for(int i=0;i<Ls.size();i++){
for(int j=0;j<Rs.size();j++){
int no1=Ls[i];
int no2=Rs[j];
int no3=isV(no1,no2);
dp[s][no3]+=(dp[s2][no1]*dp[s2][no2])*2;
}
}
}
}else{
if(Ls.size()<s2){
Ls.push_back(all[p]);
f(p+1,all,Ls,Rs);
Ls.pop_back();
}
if((p>0)&&(Rs.size()<s2)){
Rs.push_back(all[p]);
f(p+1,all,Ls,Rs);
Rs.pop_back();
}
}
}
int main(){
std::vector<int> all,Ls,Rs;
memset(dp,0,sizeof(dp));
for(int i=0;i<LIMIT;i++){
for(int j=0;j<LIMIT;j++){
scanf("%d",&data[i][j]);
}
all.push_back(i);
}
f(0,all,Ls,Rs);
for(int i=0;i<LIMIT;i++){
std::cout<<dp[LIMIT][i]<<"\n";
}
}
horiesiniti