結果

問題 No.90 品物の並び替え
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-07-20 10:47:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 58,112 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 16:59:19
合計ジャッジ時間 1,216 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0