結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2016-07-20 10:47:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 597 bytes |
| コンパイル時間 | 715 ms |
| コンパイル使用メモリ | 58,272 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 17:30:09 |
| 合計ジャッジ時間 | 1,116 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d %d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d %d %d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int sc[10][10];
int ans=0;
int n;
void f(int no,int bs,int score){
if(bs==((1<<n)-1)){
ans=std::max(ans,score);
}else{
for(int i=0;i<n;i++){
int b=(1<<i);
if((bs&b)==0){
f(i,bs|b,score+sc[no][i]);
}
}
}
}
int main() {
// your code goes here
int m;
scanf("%d %d",&n,&m);
memset(sc,0,sizeof(sc));
for(int i=0;i<m;i++){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
sc[a][b]=c;
}
for(int i=0;i<n;i++){
int b=(1<<i);
f(i,b,0);
}
std::cout<<ans<<"\n";
return 0;
}
horiesiniti