답안 #612477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
612477 2022-07-29T15:46:24 Z MohamedAliSaidane 장난감 기차 (IOI17_train) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#include "train.h"
    using namespace std;

    typedef long long ll;
    typedef double ld;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;

    typedef vector<int> vi;
    typedef vector<ll> vll;
    typedef vector<pii> vpi;
    typedef vector<pll> vpl;

    #define pb push_back
    #define popb pop_back
    #define all(x) (x).begin(),(x).end()

    #define ff first
    #define ss second

    const int nax = 5004;
    const int MOD = 1e9 + 7;
    int  n, m;
    vi adj[nax];
    int vis[nax];
    int dfs(int x, int dep = n)
    {
        vis[x] = 1;
        dep = C[x] ? n: dep;
        if(dep == 0)
            return 1 - A[x];
        int rep = 0;
        for(auto e: adj[x])
        {
            if(vis[e])
            {
                rep = rep | A[x];
            }
            else
            {
                if(A[e] == A[x])
                    rep =rep | dfs(e, dep - 1);
                else
                    rep = rep | (1 - dfs(e, dep - 1));
            }
        }
        vis[x] = 0;
        return rep;
    }
    vi who_wins(vi a, vi r, vi u, vi v)
    {
        n = a.size();
        m = u.size();
        for(int i = 0 ; i < n; i++)
        {
            A[i] = a[i];
            C[i ] = r[i];
        }
        for(int i = 0 ; i  < m; i ++)
        {
            adj[u[i]].pb(v[i]);
        }
        vi ans(n, 0);
        for(int i = 0 ; i < n; i ++)
        {
            int rep  = dfs(i, n);
            if(A[i])
                ans[i] = rep;
            else
                ans[i] = 1 - rep;
        }
        return ans;

    }

Compilation message

train.cpp: In function 'int dfs(int, int)':
train.cpp:30:15: error: 'C' was not declared in this scope
   30 |         dep = C[x] ? n: dep;
      |               ^
train.cpp:32:24: error: 'A' was not declared in this scope
   32 |             return 1 - A[x];
      |                        ^
train.cpp:38:29: error: 'A' was not declared in this scope
   38 |                 rep = rep | A[x];
      |                             ^
train.cpp:42:20: error: 'A' was not declared in this scope
   42 |                 if(A[e] == A[x])
      |                    ^
train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:57:13: error: 'A' was not declared in this scope
   57 |             A[i] = a[i];
      |             ^
train.cpp:58:13: error: 'C' was not declared in this scope
   58 |             C[i ] = r[i];
      |             ^
train.cpp:68:16: error: 'A' was not declared in this scope
   68 |             if(A[i])
      |                ^