結果

問題 No.709 優勝可能性
ユーザー kimiyukikimiyuki
提出日時 2018-06-29 23:56:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 505 ms / 3,500 ms
コード長 1,497 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 203,784 KB
実行使用メモリ 11,220 KB
最終ジャッジ日時 2023-09-13 15:51:34
合計ジャッジ時間 6,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 254 ms
8,500 KB
testcase_11 AC 179 ms
8,496 KB
testcase_12 AC 399 ms
10,216 KB
testcase_13 AC 362 ms
10,184 KB
testcase_14 AC 327 ms
10,100 KB
testcase_15 AC 302 ms
10,212 KB
testcase_16 AC 288 ms
10,516 KB
testcase_17 AC 285 ms
11,220 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 505 ms
10,092 KB
testcase_21 AC 505 ms
10,268 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    // input
    int n, m; cin >> n >> m;
    auto r = vectors(n, m, int());
    REP (y, n) REP (x, m) cin >> r[y][x];

    // solve
    vector<int> max_r(m, INT_MIN);
    vector<vector<int> > argmax_r(m);
    REP (y, n) {
        bool used = false;
        REP (x, m) {
            if (max_r[x] < r[y][x]) {
                max_r[x] = r[y][x];
                for (int y1 : argmax_r[x]) {
                    REP3 (x1, x + 1, m) {
                        if (max_r[x1] == r[y1][x1]) {
                            argmax_r[x1].push_back(y1);
                            break;
                        }
                    }
                }
                argmax_r[x].clear();
            }
            if (max_r[x] == r[y][x]) {
                if (not used) {
                    used = true;
                    argmax_r[x].push_back(y);
                }
            }
        }

        // output
        int answer = 0;
        REP (x, m) {
            answer += argmax_r[x].size();
        }
        cout << answer << endl;
    }
    return 0;
}
0