結果

問題 No.709 優勝可能性
コンテスト
ユーザー siman
提出日時 2022-08-17 17:29:52
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,094 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 697 ms
コンパイル使用メモリ 152,444 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2026-04-20 13:46:39
合計ジャッジ時間 7,312 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 6 WA * 7 TLE * 1 -- * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:12: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   19 |   int R[N][M];
      |            ^
main.cpp:19:12: note: read of non-const variable 'M' is not allowed in a constant expression
main.cpp:17:10: note: declared here
   17 |   int N, M;
      |          ^
main.cpp:19:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   19 |   int R[N][M];
      |         ^
main.cpp:19:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
   17 |   int N, M;
      |       ^
main.cpp:27:14: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   27 |   set<int> S[N];
      |              ^
main.cpp:27:14: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
   17 |   int N, M;
      |       ^
main.cpp:29:17: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   29 |   int v_counter[N];
      |                 ^
main.cpp:29:17: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
   17 |   int N, M;
      |       ^
main.cpp:31:18: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   31 |   int max_values[M];
      |                  ^
main.cpp:31:18: note: read of non-const variable 'M' is not allowed in a constant expression
main.cpp:17:10: note: declared here
   17 |   int N, M;
      |          ^
5 warnings generated.

ソースコード

diff #
raw source code

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

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

  set<int> S[N];
  int left = 0;
  int v_counter[N];
  memset(v_counter, 0, sizeof(v_counter));
  int max_values[M];
  memset(max_values, 0, sizeof(max_values));
  int ans = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if (max_values[j] < R[i][j]) {
        for (int s : S[j]) {
          v_counter[s]--;
          if (v_counter[s] == 0) {
            --ans;
          }
        }

        v_counter[i]++;
        max_values[j] = R[i][j];
        S[j].insert(i);
      } else if (max_values[j] == R[i][j]) {
        v_counter[i]++;
        S[j].insert(i);
      }
    }
    if (v_counter[i] > 0) {
      ++ans;
    }

    cout << ans << endl;
  }

  return 0;
}
0