제출 #1353613

#제출 시각아이디문제언어결과실행 시간메모리
1353613sallyPPP (EGOI23_ppp)C++20
컴파일 에러
0 ms0 KiB
// https://oj.uz/problem/view/EGOI23_ppp
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
vector<int> ans;
vector<vector<int>> g;
vector<pii> event;
vector<int> match, cnt;
void dfs(int now, int pre, int MAXN, int MAX) {
    for(int i: g[now]) {
        cout<<now<<' '<<i<<'\n';
        int win = event[i].first;
        cnt[win] += (now - i); // 持有天數+1
        int mxn = MAXN, mx = MAX;
        if(cnt[win] > mxn) {mxn = cnt[win]; mx = win;}
        else if(cnt[win] == mxn) mx = min(mx, win);
        ans[mx]++;
        dfs(i, now, mxn, mx);
        cnt[win] -= (now - i);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin>>N>>M;
    g.resize(M+2);
    ans.assign(N+2, 0);
    cnt.assign(N+2, 0);
    event.resize(M+2);
    match.assign(M+2, -1);
    for(int i=1; i<=M; i++) {
        int win, lose;
        cin>>win>>lose;
        event[i].first = win;
        event[i].second = lose;
        if(match[win]!=-1)  {g[i].push_back(match[win]);  p[match[win]]  = i;}
        if(match[lose]!=-1) {g[i].push_back(match[lose]); p[match[lose]] = i;}
        match[win] = i;
        match[lose] = -1;
    }
    for(int i=1; i<=M; i++) 
        if(p[i] == -1) g[M+1].push_back(i); // fake node
    dfs(M+1, M+1, 0, N+1);
    for(int i=0; i<N; i++) cout<<ans[i]<<' ';
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:38:59: error: 'p' was not declared in this scope
   38 |         if(match[win]!=-1)  {g[i].push_back(match[win]);  p[match[win]]  = i;}
      |                                                           ^
Main.cpp:39:59: error: 'p' was not declared in this scope
   39 |         if(match[lose]!=-1) {g[i].push_back(match[lose]); p[match[lose]] = i;}
      |                                                           ^
Main.cpp:44:12: error: 'p' was not declared in this scope
   44 |         if(p[i] == -1) g[M+1].push_back(i); // fake node
      |            ^