結果

問題 No.709 優勝可能性
ユーザー ldsybldsyb
提出日時 2018-06-30 11:59:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 484 ms / 3,500 ms
コード長 1,206 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 169,552 KB
実行使用メモリ 9,740 KB
最終ジャッジ日時 2023-09-13 16:14:47
合計ジャッジ時間 6,424 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 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,380 KB
testcase_10 AC 234 ms
4,908 KB
testcase_11 AC 164 ms
4,376 KB
testcase_12 AC 388 ms
6,544 KB
testcase_13 AC 341 ms
7,688 KB
testcase_14 AC 309 ms
7,752 KB
testcase_15 AC 285 ms
7,648 KB
testcase_16 AC 267 ms
7,892 KB
testcase_17 AC 272 ms
9,740 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 480 ms
7,704 KB
testcase_21 AC 484 ms
7,832 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int r[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> r[i][j];
        }
    }
    int maxi[m]{}, deg[n]{}, ans = 0;
    stack<int> st[m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (maxi[j] < r[i][j])
            {
                while (!st[j].empty())
                {
                    int x = st[j].top();
                    st[j].pop();
                    deg[x]--;
                    if (deg[x] == 0)
                    {
                        ans--;
                    }
                }
                st[j].push(i);
                maxi[j] = r[i][j];
                if (deg[i] == 0)
                {
                    ans++;
                }
                deg[i]++;
            }
            else if (maxi[j] == r[i][j])
            {
                if (deg[i] == 0)
                {
                    ans++;
                }
                deg[i]++;
                st[j].push(i);
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0