답안 #72592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72592 2018-08-26T10:46:30 Z vex 게임 (IOI14_game) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define n 1505
using namespace std;

int n;
int sz[maxn],p[maxn];
int uk=0;
void initialize(int N)
{
    n=N;
    for(int i=0;i<n;i++)
    {
        sz[i]=1;
        p[i]=i;
    }
}
int fnd(int x)
{
    if(x==p[x])return x;
    p[x]=fnd(p[x]);
    return p[x];
}
bool same(int x,int y)
{
    return fnd(x)==fnd(y);
}
void unite(int x,int y)
{
    x=fnd(x);
    y=fnd(y);
    if(sz[x]<sz[y])swap(x,y);
    sz[x]+=sz[y];
    p[y]=x;
}

int hasEdge(int u,int v)
{
    if(same(u,v))return 0;

    u=fnd(u);
    v=fnd(v);

    if(sz[u]+sz[v]<n)
    {
        unite(u,v);
        return 1;
    }
    return 0;
}

Compilation message

game.cpp:2:11: error: expected unqualified-id before numeric constant
 #define n 1505
           ^
game.cpp:5:5: note: in expansion of macro 'n'
 int n;
     ^
game.cpp:6:8: error: 'maxn' was not declared in this scope
 int sz[maxn],p[maxn];
        ^~~~
game.cpp:6:8: note: suggested alternative: 'tan'
 int sz[maxn],p[maxn];
        ^~~~
        tan
game.cpp:6:16: error: 'maxn' was not declared in this scope
 int sz[maxn],p[maxn];
                ^~~~
game.cpp:6:16: note: suggested alternative: 'tan'
 int sz[maxn],p[maxn];
                ^~~~
                tan
game.cpp: In function 'void initialize(int)':
game.cpp:10:7: error: lvalue required as left operand of assignment
     n=N;
       ^
game.cpp:13:9: error: 'sz' was not declared in this scope
         sz[i]=1;
         ^~
game.cpp:14:9: error: 'p' was not declared in this scope
         p[i]=i;
         ^
game.cpp: In function 'int fnd(int)':
game.cpp:19:11: error: 'p' was not declared in this scope
     if(x==p[x])return x;
           ^
game.cpp:20:5: error: 'p' was not declared in this scope
     p[x]=fnd(p[x]);
     ^
game.cpp: In function 'void unite(int, int)':
game.cpp:31:8: error: 'sz' was not declared in this scope
     if(sz[x]<sz[y])swap(x,y);
        ^~
game.cpp:32:5: error: 'sz' was not declared in this scope
     sz[x]+=sz[y];
     ^~
game.cpp:33:5: error: 'p' was not declared in this scope
     p[y]=x;
     ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:43:8: error: 'sz' was not declared in this scope
     if(sz[u]+sz[v]<n)
        ^~