제출 #1352525

#제출 시각아이디문제언어결과실행 시간메모리
1352525sallyPPP (EGOI23_ppp)C++20
16 / 100
3095 ms3512 KiB
// https://oj.uz/problem/view/EGOI23_ppp
#include<iostream>
#include<vector>
using namespace std;
#define winner first
#define loser second
typedef pair<int,int> pii;
int main() {
    int N, M;
    cin>>N>>M;
    vector<pii> event(M);
    for(int i=0; i<M; i++) {
        int win, lose;
        cin>>win>>lose;
        event[i].winner = win;
        event[i].loser = lose;
    }
    vector<int> ans(N, 0);
    for(int medal = 0; medal<M; medal++) {
        vector<int> cnt(N, 0);
        int MAXN = N+1, MAX = 0;
        int now = event[medal].winner;
        cnt[now]++;
        MAXN = now;
        MAX = 1;
        for(int i = medal+1; i<M; i++) {
            if(event[i].loser!=now) {
                cnt[now]++;
                if(cnt[now] == MAX) MAXN = min(MAXN, now);
                else if(cnt[now] > MAX) {
                    MAX = cnt[now];
                    MAXN = now;
                }
                continue;
            }
            now = event[i].winner;
            cnt[now]++;
            if(cnt[now] == MAX) MAXN = min(MAXN, now);
            else if(cnt[now] > MAX) {
                MAX = cnt[now];
                MAXN = now;
            }
        }
        ans[MAXN]++;
        //cout<<"medal = "<<medal<<", winner = "<<MAXN<<"\n";
    }
    for(int i=0; i<N; i++) cout<<ans[i]<<' ';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...