結果

問題 No.709 優勝可能性
ユーザー KKT89
提出日時 2020-07-14 01:16:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 126 ms / 3,500 ms
コード長 1,186 bytes
コンパイル時間 1,021 ms
コンパイル使用メモリ 110,732 KB
最終ジャッジ日時 2025-01-11 20:24:01
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

vector<int> v[100100];
int a[100100][11];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int res=0;
    vector<int> mx(m,-1),cnt(n,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(mx[j]==a[i][j]){
                v[j].push_back(i);
                if(cnt[i]==0)res++;
                cnt[i]++;
            }
            else if(mx[j]<a[i][j]){
                mx[j]=a[i][j];
                while(v[j].size()){
                    int p=v[j].back(); v[j].pop_back();
                    cnt[p]--;
                    if(cnt[p]==0)res--;
                }
                if(cnt[i]==0)res++;
                cnt[i]++;
                v[j].push_back(i);
            }
        }
        printf("%d\n",res);
    }
}
0