結果

問題 No.134 走れ!サブロー君
ユーザー orange orangeorange orange
提出日時 2023-10-16 20:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,471 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 100,832 KB
実行使用メモリ 4,936 KB
最終ジャッジ日時 2023-10-16 20:12:55
合計ジャッジ時間 2,261 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<climits>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<assert.h>
#include<numeric>
#include<bitset>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
using namespace std;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 62;
const double PI = 2 * acos(0.0);
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }

int N;
double X[20], Y[20], W[20];
double dp[10000][20];
int main() {
	cin >> X[0] >> Y[0];
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i] >> Y[i] >> W[i];
	for (int i = 0; i < 1 << (N + 1); i++) for (int j = 0; j < N + 1; j++) dp[i][j] = infl;
	dp[0][0] = 0;

	for (int msk = 0; msk < 1 << (N + 1); msk++) {
		double w = 0;
		for (int i = 0; i < N + 1; i++) if (!(msk & 1 << i)) w += W[i];
		double T = (w + 100) / 120;

		for (int i = 0; i < N + 1; i++) {
			for (int j = 0; j < N + 1; j++) {
				if (msk & 1 << j) continue;
				double dis = abs(X[j] - X[i]) + abs(Y[j] - Y[i]);
				chmin(dp[msk + (1 << j)][j], dp[msk][i] + dis * T + W[i]);
			}
		}
	}
	
	cout << dp[(1 << (N + 1)) - 1][0] << endl;
}
0