結果

問題 No.709 優勝可能性
ユーザー le_panda_noirle_panda_noir
提出日時 2020-07-10 23:24:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 725 ms / 3,500 ms
コード長 949 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 90,696 KB
実行使用メモリ 43,948 KB
最終ジャッジ日時 2024-04-19 23:57:06
合計ジャッジ時間 6,341 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 236 ms
11,648 KB
testcase_11 AC 162 ms
11,392 KB
testcase_12 AC 406 ms
13,696 KB
testcase_13 AC 372 ms
12,928 KB
testcase_14 AC 305 ms
13,056 KB
testcase_15 AC 297 ms
13,440 KB
testcase_16 AC 421 ms
17,536 KB
testcase_17 AC 725 ms
43,948 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 490 ms
12,800 KB
testcase_21 AC 497 ms
12,928 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N, M; cin >> N >> M;

  vector<vector<int>> R(N, vi(M));
  rep(i, N) {
    rep(j, M) {
      cin >> R[i][j];
    }
  }
  vi max_R(N, 0);
  vector<vi> maxes(N, vi());
  multiset<int> tmp;
  set<int> ans;
  rep(k, N) {
    rep(j, M) {
      if (max_R[j] > R[k][j])
        continue;
      if (max_R[j] == R[k][j]) {
        tmp.insert(k);
        ans.insert(k);
        maxes[j].push_back(k);
        continue;
      }
      while (!maxes[j].empty()) {
        int v = maxes[j].back(); maxes[j].pop_back();
        tmp.erase(tmp.lower_bound(v));
        if (tmp.find(v) == tmp.end())
          ans.erase(v);
      }
      tmp.insert(k);
      ans.insert(k);
      maxes[j].push_back(k);
      max_R[j] = R[k][j];
    }
    cout << ans.size() << endl;
  }

  return 0;
}
0