結果

問題 No.709 優勝可能性
ユーザー donkorin_donkorin_
提出日時 2018-09-11 10:37:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 3,500 ms
コード長 1,566 bytes
コンパイル時間 3,021 ms
コンパイル使用メモリ 171,572 KB
実行使用メモリ 9,588 KB
最終ジャッジ日時 2023-09-05 07:29:25
合計ジャッジ時間 7,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 170 ms
7,736 KB
testcase_11 AC 141 ms
7,656 KB
testcase_12 AC 206 ms
7,888 KB
testcase_13 AC 204 ms
7,636 KB
testcase_14 AC 202 ms
7,676 KB
testcase_15 AC 193 ms
7,696 KB
testcase_16 AC 193 ms
7,996 KB
testcase_17 AC 192 ms
9,588 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 238 ms
7,396 KB
testcase_21 AC 238 ms
7,416 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, r[100005][10], d[100005], k[10], ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<stack<int> > st(m);
    rep(i, 0, n) rep(j, 0, m) cin >> r[i][j];
    rep(i, 0, n) {
        rep(j, 0, m) {
            if (k[j] < r[i][j]) {
                while (!st[j].empty()) {
                    int p = st[j].top(); st[j].pop();
                    d[p]--;
                    if (d[p] == 0) ans--;
                }
                k[j] = r[i][j];
                d[i]++;
                if (d[i] == 1) ans++;
                st[j].push(i);
            } else if (k[j] == r[i][j]) {
                d[i]++;
                st[j].push(i);
                if (d[i] == 1) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0