結果

問題 No.709 優勝可能性
ユーザー 0w10w1
提出日時 2018-10-19 15:04:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,249 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 212,632 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-04-28 18:37:42
合計ジャッジ時間 11,244 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 222 ms
8,708 KB
testcase_11 AC 156 ms
8,704 KB
testcase_12 AC 1,133 ms
10,240 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

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];

  vector<tuple<vector<int>, int>> dp(1 << M);
  for (int s = 1; s < 1 << M; ++s) dp[s] = make_tuple(vector<int>(M), 0);

  for (int i = 0; i < N; ++i) {
    int ans = 0;
    for (int s = 1; s < 1 << M; ++s) {
      bool ng = false;
      bool better = false;
      vector<int> cur(M);
      vector<int> xxx(M);
      for (int j = 0; j < M; ++j) {
        if (s >> j & 1) {
          cur[j] = R[i][j];
          xxx[j] = max(R[i][j], get<0>(dp[s])[j]);
          ng |= R[i][j] < get<0>(dp[s])[j];
          better |= R[i][j] > get<0>(dp[s])[j];
        }
      }
      if (!ng && better) dp[s] = make_tuple(cur, 1);
      else if (!ng && !better) ++get<1>(dp[s]);
      else if (ng && better) dp[s] = make_tuple(xxx, 0);
      ans += (__builtin_popcount(s) & 1 ? 1 : -1) * get<1>(dp[s]);
      // cout << "dp[" << i << "][" << s << "] = " << get<0>(dp[s])[0] << " " << get<0>(dp[s])[1] << " " << get<0>(dp[s])[2] << " " << get<1>(dp[s]) << endl;
    }
    cout << ans << endl;
  }

  return 0;
}
0