답안 #850095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850095 2023-09-15T17:55:26 Z alexdd Amusement Park (JOI17_amusement_park) C++17
0 / 100
37 ms 11872 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static void dfs(int nod)
{
    visited[nod]=1;
    sort(con[nod].begin(),con[nod].end());
    ord.push_back(nod);
    for(auto adj:con[nod])
    {
        if(!visited[adj])
        {
            dfs(adj);
            ord.push_back(nod);
        }
    }
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
    ord.clear();
    for(int i=0;i<N;i++)
    {
        visited[i]=0;
        con[i].clear();
        done[i]=0;
    }

    for(int i=0;i<M;i++)
    {
        con[A[i]].push_back(B[i]);
        con[B[i]].push_back(A[i]);
    }
    dfs(0);
    int cnt=0;
    for(int i=0;i<(int)ord.size();i++)
    {
        if(!done[ord[i]])
        {
            if(((1LL<<cnt)&X))
                MessageBoard(ord[i],1);
            else
                MessageBoard(ord[i],0);
            cnt++;
            done[ord[i]]=1;
        }
    }
}


#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static int p[10005];
static int poz[10005];
static int fr[65];
static int care[10005];
map<pair<int,int>,int> edges;
static void dfs(int nod)
{
    visited[nod]=1;
    sort(con[nod].begin(),con[nod].end());
    poz[nod]=ord.size();
    ord.push_back(nod);
    for(auto adj:con[nod])
    {
        if(!visited[adj])
        {
            dfs(adj);
            ord.push_back(nod);
        }
    }
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
    ord.clear();
    for(int i=0;i<N;i++)
    {
        visited[i]=0;
        con[i].clear();
        done[i]=0;
    }
    for(int i=0;i<60;i++)
        fr[i]=0;

    for(int i=0;i<M;i++)
    {
        con[A[i]].push_back(B[i]);
        con[B[i]].push_back(A[i]);
        edges[{A[i],B[i]}]++;
        edges[{B[i],A[i]}]++;
    }
    dfs(0);
    int cnt=0;
    for(int i=0;i<(int)ord.size();i++)
    {
        if(!done[ord[i]])
        {
            care[ord[i]]=cnt;
            cnt=(cnt+1)%60;
            done[ord[i]]=1;
        }
        p[i]=care[ord[i]];
    }
    for(int i=0;i<(int)ord.size()-1;i++)
    {
        if(edges[{ord[i],ord[i+1]}]==0)
        {
            while(1)
                N=0;
        }
    }
    long long rez=0;
    int cate=0;
    for(int i=poz[P];i<(int)ord.size();i++)
    {
        if(fr[p[i]]==0)
        {
            rez += V * (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                return rez;
        }
        if(i+1<(int)ord.size()) V = Move(ord[i+1]);
    }
    while(1)
        N=0;
    for(int i=(int)ord.size()-1;i>=0;i--)
    {
        if(fr[p[i]]==0)
        {
            rez += V * (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                return rez;
        }
        if(i==0)
        {
            while(1)
                i=1;
        }
        V = Move(ord[i-1]);
    }
    return rez;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1288 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 11776 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1292 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 37 ms 11872 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 11728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -