結果

問題 No.709 優勝可能性
ユーザー 0w10w1
提出日時 2018-10-19 15:14:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 263 ms / 3,500 ms
コード長 745 bytes
コンパイル時間 3,609 ms
コンパイル使用メモリ 208,648 KB
実行使用メモリ 14,916 KB
最終ジャッジ日時 2023-08-11 01:53:02
合計ジャッジ時間 7,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 169 ms
9,092 KB
testcase_11 AC 148 ms
9,108 KB
testcase_12 AC 222 ms
10,536 KB
testcase_13 AC 226 ms
10,604 KB
testcase_14 AC 214 ms
10,392 KB
testcase_15 AC 207 ms
10,328 KB
testcase_16 AC 212 ms
10,964 KB
testcase_17 AC 219 ms
14,916 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 263 ms
10,624 KB
testcase_21 AC 258 ms
10,552 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;

signed main() {
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<vector<int>> R(N, vector<int>(M));
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      cin >> R[i][j];

  int ans = 0;
  vector<int> stats(N);
  vector<stack<pair<int, int>>> stks(M);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      for (; stks[j].size() && stks[j].top().first < R[i][j]; stks[j].pop()) {
        if (--stats[stks[j].top().second] == 0) --ans;
      }
      if (stks[j].empty() || R[i][j] == stks[j].top().first) {
        ++stats[i];
        stks[j].emplace(R[i][j], i);
      }
    }
    if (stats[i]) ++ans;
    cout << ans << endl;
  }

  return 0;
}
0