답안 #476980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476980 2021-09-29T16:18:18 Z nicolaalexandra Amusement Park (JOI17_amusement_park) C++14
0 / 100
7 ms 1148 KB
#include <bits/stdc++.h>
#include "Joi.h"
#define DIM 1010
using namespace std;

static vector <int> L[DIM];
static int viz[DIM],val[DIM],idx,n;

/*void MessageBoard (int x, int y){
    return;
}
*/

void dfs (int nod){

    viz[nod] = 1;
    val[nod] = (++idx) % 60; /// ce bit ii atribui

    for (auto vecin : L[nod])
        if (!viz[vecin])
            dfs (vecin);
}

void Joi (int _n, int m, int a[], int b[], long long x, int useless){
    n = _n;
    for (int i=0;i<m;i++){
        a[i]++, b[i]++;
        L[a[i]].push_back(b[i]);
        L[b[i]].push_back(a[i]);
    }

    memset (viz,0,sizeof viz);
    memset (val,0,sizeof val);
    idx = -1;
    dfs (1);

    for (int i=1;i<=n;i++){
        int bit = val[i];
        if (x & (1LL<<bit))
             MessageBoard(i-1,1);
        else  MessageBoard(i-1,0);
    }

}

#include <bits/stdc++.h>
#include "Ioi.h"
#define DIM 1010
using namespace std;


static vector <int> L[DIM],edg[DIM];
static int viz[DIM],val[DIM],fth[DIM],s[DIM],f[70],idx,n,cnt;


/*int Move (int dest){
    //return value[dest+1];
}
*/

void add_edge (int x, int y){
    edg[x].push_back(y);
    edg[y].push_back(x);
}

void dfs (int nod){

    viz[nod] = s[nod] = 1;
    val[nod] = (++idx) % 60; /// ce bit ii atribui

    for (auto vecin : L[nod])
        if (!viz[vecin]){
            fth[vecin] = nod;
            add_edge (nod,vecin);
            dfs (vecin);
            s[nod] += s[vecin];
        }
}

void dfs2 (int nod, int tata){
    if (cnt == 60)
        return;
    for (auto vecin : edg[nod])
        if (vecin != tata){
            int ans = Move(vecin-1);

            if (f[val[vecin]] == -1)
                cnt++;
            f[val[vecin]] = ans;

            if (cnt == 60)
                return;

            dfs2 (vecin,nod);
            Move(nod-1); /// trb sa ma intorc inapoi
        }

}

long long Ioi (int n, int m, int a[], int b[], int start, int val_start, int useless){

    for (int i=0;i<m;i++){
        L[a[i]].push_back(b[i]);
        L[b[i]].push_back(a[i]);
    }

    //memset (viz,0,sizeof viz);
    //memset (val,0,sizeof val);
    idx = -1;
    dfs (0);
    fth[0] = -1;

    memset (f,-1,sizeof f);


    cnt = 0;
    if (f[val[start]] == -1){
        f[val[start]] = val_start;
        cnt = 1;
    }

    while (s[start] < 60){
        start = fth[start];
        Move(start);
    }


    dfs2 (start,fth[start]);

    long long sol = 0;
    for (int i=0;i<60;i++)
        if (f[i])
            sol += (1LL<<i);
    return sol;
}


/*int main (){

    ifstream cin ("date.in");
    ofstream cout ("date.out");


    return 0;
}*/

Compilation message

Ioi.cpp:8:56: warning: 'n' defined but not used [-Wunused-variable]
    8 | static int viz[DIM],val[DIM],fth[DIM],s[DIM],f[70],idx,n,cnt;
      |                                                        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 744 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 756 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -