답안 #68886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68886 2018-08-19T00:54:09 Z duality Amusement Park (JOI17_amusement_park) C++14
0 / 100
88 ms 14856 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "Joi.h"

static int parent[10000];
static int find(int n) {
    if (parent[n] != n) parent[n] = find(parent[n]);
    return parent[n];
}
static vpii edges;
static vi adjList[10000];
static vpii sub[10000];
static int num[10000];
static int doDFS(int u,int p) {
    int i;
    if (sub[0].size() < 60) num[u] = sub[0].size(),sub[0].pb(mp(u,0));
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS(v,u);
    }
    return 0;
}
static int doDFS2(int u,int p) {
    int i;
    if (p != -1) {
        for (i = 0; i < 60; i++) {
            if (sub[p][i].first == u) break;
        }
        sub[u] = sub[p];
        if (i == 60) {
            for (i = 0; i < 60; i++) {
                if ((sub[u][i].first != p) && (sub[u][i].second == 1)) break;
            }
            int x = i;
            for (i = 0; i < 60; i++) {
                if (sub[u][i].first == p) {
                    sub[u][i].second++;
                    break;
                }
            }
            for (i = 0; i < 60; i++) {
                if (binary_search(edges.begin(),edges.end(),mp(sub[u][x].first,sub[u][i].first))) {
                    sub[u][i].second--;
                    break;
                }
            }
            num[u] = num[sub[u][x].first];
            sub[u][x].first = u;
        }
    }
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS2(v,u);
    }
    return 0;
}
void Joi(int N,int M,int A[],int B[],long long int X,int T) {
    int i;
    for (i = 0; i < N; i++) parent[i] = i;
    for (i = 0; i < M; i++) {
        int pa = find(A[i]),pb = find(B[i]);
        if (pa != pb) {
            parent[pa] = pb;
            adjList[A[i]].pb(B[i]);
            adjList[B[i]].pb(A[i]);
            edges.pb(mp(A[i],B[i]));
            edges.pb(mp(B[i],A[i]));
        }
    }
    sort(edges.begin(),edges.end());
    int j,k;
    doDFS(0,-1);
    for (i = 0; i < 60; i++) {
        for (j = 0; j < adjList[sub[0][i].first].size(); j++) {
            for (k = 0; k < 60; k++) {
                if (adjList[sub[0][i].first][j] == sub[0][k].first) sub[0][i].second++;
            }
        }
    }
    doDFS2(0,-1);
    for (i = 0; i < N; i++) MessageBoard(i,(X & (1LL << num[i])) > 0);
}
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "Ioi.h"

static int parent[10000];
static int find(int n) {
    if (parent[n] != n) parent[n] = find(parent[n]);
    return parent[n];
}
static vpii edges;
static vi adjList[10000];
static vpii sub[10000];
static int num[10000];
static int doDFS(int u,int p) {
    int i;
    if (sub[0].size() < 60) num[u] = sub[0].size(),sub[0].pb(mp(u,0));
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS(v,u);
    }
    return 0;
}
static int doDFS2(int u,int p) {
    int i;
    if (p != -1) {
        for (i = 0; i < 60; i++) {
            if (sub[p][i].first == u) break;
        }
        sub[u] = sub[p];
        if (i == 60) {
            for (i = 0; i < 60; i++) {
                if ((sub[u][i].first != p) && (sub[u][i].second == 1)) break;
            }
            int x = i;
            for (i = 0; i < 60; i++) {
                if (sub[u][i].first == p) {
                    sub[u][i].second++;
                    break;
                }
            }
            for (i = 0; i < 60; i++) {
                if (binary_search(edges.begin(),edges.end(),mp(sub[u][x].first,sub[u][i].first))) {
                    sub[u][i].second--;
                    break;
                }
            }
            num[u] = num[sub[u][x].first];
            sub[u][x].first = u;
        }
    }
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS2(v,u);
    }
    return 0;
}
static LLI ans = 0;
static int insub[10000],message[10000];
static int doDFS3(int u,int p) {
    int i;
    if (message[u]) ans |= (1LL << num[u]);
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if ((v != p) && insub[v]) {
            message[v] = Move(v);
            doDFS3(v,u);
            Move(u);
        }
    }
    return 0;
}
long long int Ioi(int N,int M,int A[],int B[],int P,int V,int T) {
    int i;
    for (i = 0; i < N; i++) parent[i] = i;
    for (i = 0; i < M; i++) {
        int pa = find(A[i]),pb = find(B[i]);
        if (pa != pb) {
            parent[pa] = pb;
            adjList[A[i]].pb(B[i]);
            adjList[B[i]].pb(A[i]);
            edges.pb(mp(A[i],B[i]));
            edges.pb(mp(B[i],A[i]));
        }
    }
    sort(edges.begin(),edges.end());
    int j,k;
    doDFS(0,-1);
    for (i = 0; i < 60; i++) {
        for (j = 0; j < adjList[sub[0][i].first].size(); j++) {
            for (k = 0; k < 60; k++) {
                if (adjList[sub[0][i].first][j] == sub[0][k].first) sub[0][i].second++;
            }
        }
    }
    doDFS2(0,-1);
    for (i = 0; i < 60; i++) insub[sub[P][i].first] = 1;
    doDFS3(P,-1);
    return ans;
}

Compilation message

Joi.cpp: In function 'int doDFS(int, int)':
Joi.cpp:71:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Joi.cpp: In function 'int doDFS2(int, int)':
Joi.cpp:105:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:128:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < adjList[sub[0][i].first].size(); j++) {
                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ioi.cpp: In function 'int doDFS(int, int)':
Ioi.cpp:71:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp: In function 'int doDFS2(int, int)':
Ioi.cpp:105:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp: In function 'int doDFS3(int, int)':
Ioi.cpp:116:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:143:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < adjList[sub[0][i].first].size(); j++) {
                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1872 KB Output is correct
2 Correct 6 ms 2048 KB Output is correct
3 Correct 7 ms 2292 KB Output is correct
4 Incorrect 7 ms 2296 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 14516 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 14856 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 14856 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 14856 KB Output is correct
2 Correct 82 ms 14856 KB Output is correct
3 Incorrect 88 ms 14856 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -