結果

問題 No.3674 Zero Sum Game
コンテスト
ユーザー 👑 みうね
提出日時 2026-08-22 14:22:50
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,745 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,126 ms
コンパイル使用メモリ 175,416 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-09-04 22:32:27
合計ジャッジ時間 71,922 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using Matrix = std::vector<std::vector<double>>;

// Intentionally incorrect: fixed-iteration fictitious play converges too
// slowly to guarantee the accuracy required by the problem.
double solve(const Matrix& a) {
    constexpr int iterations = 200000;
    const int n = static_cast<int>(a.size());
    const int m = static_cast<int>(a[0].size());
    std::vector<double> row_sum(n, 0.0);
    std::vector<double> column_sum(m, 0.0);
    int alice = 0;
    int bob = 0;

    for (int iteration = 0; iteration < iterations; ++iteration) {
        if (iteration != 0) {
            alice = static_cast<int>(
                std::max_element(row_sum.begin(), row_sum.end())
                - row_sum.begin());
            bob = static_cast<int>(
                std::min_element(column_sum.begin(), column_sum.end())
                - column_sum.begin());
        }
        for (int i = 0; i < n; ++i) row_sum[i] += a[i][bob];
        for (int j = 0; j < m; ++j) column_sum[j] += a[alice][j];
    }

    const double lower =
        *std::min_element(column_sum.begin(), column_sum.end()) / iterations;
    const double upper =
        *std::max_element(row_sum.begin(), row_sum.end()) / iterations;
    return (lower + upper) / 2;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int tests;
    std::cin >> tests;
    std::cout << std::fixed << std::setprecision(15);
    while (tests--) {
        int n, m;
        std::cin >> n >> m;
        Matrix a(n, std::vector<double>(m));
        for (auto& row : a)
            for (double& value : row)
                std::cin >> value;
        std::cout << solve(a) << '\n';
    }
}
0