結果

問題 No.5020 Averaging
ユーザー 遭難者遭難者
提出日時 2024-02-25 16:34:20
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 904 ms / 1,000 ms
コード長 2,646 bytes
コンパイル時間 7,698 ms
コンパイル使用メモリ 344,352 KB
実行使用メモリ 6,676 KB
スコア 32,033,489
最終ジャッジ日時 2024-02-25 16:35:16
合計ジャッジ時間 54,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 903 ms
6,676 KB
testcase_01 AC 903 ms
6,676 KB
testcase_02 AC 903 ms
6,676 KB
testcase_03 AC 903 ms
6,676 KB
testcase_04 AC 904 ms
6,676 KB
testcase_05 AC 903 ms
6,676 KB
testcase_06 AC 903 ms
6,676 KB
testcase_07 AC 903 ms
6,676 KB
testcase_08 AC 902 ms
6,676 KB
testcase_09 AC 903 ms
6,676 KB
testcase_10 AC 903 ms
6,676 KB
testcase_11 AC 903 ms
6,676 KB
testcase_12 AC 903 ms
6,676 KB
testcase_13 AC 903 ms
6,676 KB
testcase_14 AC 903 ms
6,676 KB
testcase_15 AC 903 ms
6,676 KB
testcase_16 AC 903 ms
6,676 KB
testcase_17 AC 903 ms
6,676 KB
testcase_18 AC 902 ms
6,676 KB
testcase_19 AC 902 ms
6,676 KB
testcase_20 AC 903 ms
6,676 KB
testcase_21 AC 904 ms
6,676 KB
testcase_22 AC 903 ms
6,676 KB
testcase_23 AC 903 ms
6,676 KB
testcase_24 AC 903 ms
6,676 KB
testcase_25 AC 903 ms
6,676 KB
testcase_26 AC 903 ms
6,676 KB
testcase_27 AC 903 ms
6,676 KB
testcase_28 AC 903 ms
6,676 KB
testcase_29 AC 902 ms
6,676 KB
testcase_30 AC 903 ms
6,676 KB
testcase_31 AC 903 ms
6,676 KB
testcase_32 AC 903 ms
6,676 KB
testcase_33 AC 902 ms
6,676 KB
testcase_34 AC 903 ms
6,676 KB
testcase_35 AC 903 ms
6,676 KB
testcase_36 AC 903 ms
6,676 KB
testcase_37 AC 903 ms
6,676 KB
testcase_38 AC 903 ms
6,676 KB
testcase_39 AC 903 ms
6,676 KB
testcase_40 AC 902 ms
6,676 KB
testcase_41 AC 903 ms
6,676 KB
testcase_42 AC 903 ms
6,676 KB
testcase_43 AC 903 ms
6,676 KB
testcase_44 AC 903 ms
6,676 KB
testcase_45 AC 903 ms
6,676 KB
testcase_46 AC 903 ms
6,676 KB
testcase_47 AC 903 ms
6,676 KB
testcase_48 AC 903 ms
6,676 KB
testcase_49 AC 903 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(a) a.begin(), a.end()
typedef long double ldouble;
#undef long
#define long long long
#define vec vector
using namespace std;
using mint = atcoder::modint;
ostream &operator<<(ostream &os, mint a)
{
	return os << a.val();
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &a)
{
	const int n = a.size();
	rep(i, n)
	{
		os << a[i];
		if (i + 1 != n)
			os << " ";
	}
	return os;
}
template <typename T, size_t n>
ostream &operator<<(ostream &os, array<T, n> &a)
{
	rep(i, n) os << a[i] << " \n"[i + 1 == n];
	return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &a)
{
	for (T &i : a)
		is >> i;
	return is;
}
template <typename T>
bool chmin(T &x, T y)
{
	if (x > y)
	{
		x = y;
		return true;
	}
	return false;
}
template <typename T>
bool chmax(T &x, T y)
{
	if (x < y)
	{
		x = y;
		return true;
	}
	return false;
}
void solve()
{
	const auto start = chrono::system_clock::now();
	constexpr int n = 45;
	int muda;
	cin >> muda;
	assert(muda == n);
	array<long, n> a, b;
	rep(i, n) cin >> a[i] >> b[i];
	array<long, n> aa, bb;
	constexpr int m = 50;
	array<int, m> ansu, ansv;
	constexpr long inf = 5e17;
	long ans = 7e18;
	array<int, m> u, v;
	while (true)
	{
		const auto now_time = chrono::system_clock::now();
		const auto elapsed_time = chrono::duration_cast<chrono::milliseconds>(now_time - start).count();
		if (elapsed_time > 900)
			break;
		rep(i, m - 1)
		{
			u[i] = rand() % n;
			v[i] = rand() % (n - 1);
			if (v[i] >= u[i])
				v[i]++;
		}
		rep(i, n)
		{
			aa[i] = a[i];
			bb[i] = b[i];
		}
		rep(i, m - 1)
		{
			aa[u[i]] = aa[v[i]] = (aa[u[i]] + aa[v[i]]) / 2;
			bb[u[i]] = bb[v[i]] = (bb[u[i]] + bb[v[i]]) / 2;
		}
		u[m - 1] = 0;
		rep(i, n)
		{
			v[m - 1] = i;
			const long a0 = aa[0], ai = aa[i];
			aa[0] = aa[i] = (a0 + ai) / 2;
			const long b0 = bb[0], bi = bb[i];
			bb[0] = bb[i] = (b0 + bi) / 2;
			if (chmin(ans, max(abs(aa[0] - inf), abs(bb[0] - inf))))
			{
				rep(i, m) ansu[i] = u[i];
				rep(i, m) ansv[i] = v[i];
			}
			aa[0] = a0, aa[i] = ai;
			bb[0] = b0, bb[i] = bi;
		}
	}
	int x = m;
	rep(i, m) if (ansu[i] == ansv[i]) x--;
	cout << x << '\n';
	rep(i, m) if (ansu[i] != ansv[i]) cout << ansu[i] + 1 << " " << ansv[i] + 1 << '\n';
}
int main()
{
	srand((unsigned)time(NULL));
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	// cout << fixed << setprecision(400);
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
	return 0;
}
0