結果

問題 No.709 優勝可能性
ユーザー 0w10w1
提出日時 2018-10-19 15:14:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 3,500 ms
コード長 745 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 211,988 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2024-04-28 19:02:36
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 181 ms
8,960 KB
testcase_11 AC 153 ms
9,088 KB
testcase_12 AC 238 ms
10,752 KB
testcase_13 AC 236 ms
10,624 KB
testcase_14 AC 227 ms
10,616 KB
testcase_15 AC 225 ms
10,752 KB
testcase_16 AC 217 ms
11,264 KB
testcase_17 AC 224 ms
14,848 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 267 ms
10,620 KB
testcase_21 AC 275 ms
10,624 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,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