답안 #850034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850034 2023-09-15T16:26:28 Z alexdd Amusement Park (JOI17_amusement_park) C++17
0 / 100
19 ms 7124 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<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 int INF = 1e9;
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 prima[65];
static int ultima[65];
static bool frst[65];
static bool frdr[65];
static int fr[65];
static int care[10005];
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<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<60;i++)
        prima[i]=-1;
    for(int i=0;i<ord.size();i++)
    {
        if(!done[ord[i]])
        {
            care[ord[i]]=cnt;
            ultima[cnt]=ord[i];
            if(prima[cnt]==-1)
                prima[cnt]=i;
            cnt=(cnt+1)%60;
            done[ord[i]]=1;
        }
        p[i]=care[ord[i]];
    }
    long long rez=0;
    int cntst=0,cntdr=0;
    for(int i=poz[P];i>=0;i--)
    {
        if(frst[p[i]]==0)
            cntst++;
        frst[p[i]]=1;
    }
    for(int i=poz[P];i<ord.size();i++)
    {
        if(frdr[p[i]]==0)
            cntdr++;
        frdr[p[i]]=1;
    }
    int cate=0;
    for(int i=poz[P];i<ord.size();i++)
    {
        if(fr[p[i]]==0)
        {
            rez += V * (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                break;
        }
        if(i+1<ord.size()) V = Move(ord[i+1]);
    }
    if(cate==60)
        return rez;
    for(int i=ord.size()-2;i>=0;i--)
    {
        if(fr[p[i]]==0)
        {
            rez += V * (1LL<<(p[i]));
            fr[p[i]]=1;
            cate++;
            if(cate==60)
                break;
        }
        V = Move(ord[i-1]);
    }
    return rez;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<ord.size();i++)
      |                 ~^~~~~~~~~~~

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0;i<ord.size();i++)
      |                 ~^~~~~~~~~~~
Ioi.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for(int i=poz[P];i<ord.size();i++)
      |                      ~^~~~~~~~~~~
Ioi.cpp:79:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for(int i=poz[P];i<ord.size();i++)
      |                      ~^~~~~~~~~~~
Ioi.cpp:89:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         if(i+1<ord.size()) V = Move(ord[i+1]);
      |            ~~~^~~~~~~~~~~
Ioi.cpp: At global scope:
Ioi.cpp:4:12: warning: 'INF' defined but not used [-Wunused-variable]
    4 | static int INF = 1e9;
      |            ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1308 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1308 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 7124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -