結果

問題 No.5023 Airlines Optimization
コンテスト
ユーザー square1001
提出日時 2026-02-25 20:59:12
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 1,444 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,445 ms
コンパイル使用メモリ 117,676 KB
実行使用メモリ 7,848 KB
スコア 40,645,958
最終ジャッジ日時 2026-02-25 20:59:19
合計ジャッジ時間 6,690 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cmath>
#include <vector>
#include <iostream>
using namespace std;

using ll = long long;

string convert_int_time(int x) {
	int h = x / 12 + 6;
	int m = (x % 12) * 5;
	string res;
	res += h / 10 + '0';
	res += h % 10 + '0';
	res += ':';
	res += m / 10 + '0';
	res += m % 10 + '0';
	return res;
}

int main() {
	int N, R;
	cin >> N >> R;
	vector<int> X(N), Y(N), W(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i] >> W[i];
	}
	vector<vector<bool>> far(N, vector<bool>(N));
	vector<vector<int>> d(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			double z = hypot(X[i] - X[j], Y[i] - Y[j]);
			far[i][j] = (z >= 250.0);
			d[i][j] = (i != j ? ceil(z * 0.015 + 8) : 0);
		}
	}
	pair<ll, int> hub_opt = {7LL << 58, -1};
	for (int i = 0; i < N; i++) {
		ll total = 0;
		for (int j = 0; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (far[j][k]) {
					total += (ll)(d[j][i] + d[k][i]) * W[j] * W[k];
				}
			}
		}
		hub_opt = min(hub_opt, {total, i});
	}
	int hub = hub_opt.second;
	const int K = 25;
	for (int i = 0; i < K; i++) {
		int p = i + (int)(i >= hub);
		int c = 180 / d[hub][p];
		cout << c << endl;
		for (int j = 0; j < c; j++) {
			int a = (j % 2 == 0 ? p : hub);
			int s = j * d[hub][p];
			int b = (hub + p) - a;
			int t = (j + 1) * d[hub][p];
			cout << a + 1 << ' ' << convert_int_time(s) << ' ' << b + 1 << ' ' << convert_int_time(t) << endl;
		}
	}
	return 0;
}
0