제출 #1333960

#제출 시각아이디문제언어결과실행 시간메모리
1333960nguyen도서관 (JOI18_library)C++20
컴파일 에러
0 ms0 KiB
#include <cstdio>
#include <vector>

#include "library.h"
using namespace std;
pair<int,int> adj[1005];

void Solve(int N)
{
    for(int i=0;i<N;i++)
        adj[i]={-1,-1};

    for(int i=0;i<N;i++)
    {
        if(adj[i].second!=-1) continue;

        int except = adj[i].first;

        int nb = find_neighbor(N,i,except);

        if(nb==-1) continue;

        if(adj[i].first==-1) adj[i].first=nb;
        else adj[i].second=nb;

        if(adj[nb].first==-1) adj[nb].first=i;
        else adj[nb].second=i;
    }

    vector<int> res;
    vector<bool> vis(N,false);

    int start=-1;

    for(int i=0;i<N;i++)
    {
        int deg=0;
        if(adj[i].first!=-1) deg++;
        if(adj[i].second!=-1) deg++;

        if(deg==1)
        {
            start=i;
            break;
        }
    }

    while(start!=-1)
    {
        res.push_back(start+1);
        vis[start]=true;

        int next=-1;

        if(adj[start].first!=-1 && !vis[adj[start].first])
            next=adj[start].first;
        else if(adj[start].second!=-1 && !vis[adj[start].second])
            next=adj[start].second;

        start=next;
    }

    Answer(res);
}

컴파일 시 표준 에러 (stderr) 메시지

library.cpp: In function 'void Solve(int)':
library.cpp:19:18: error: 'find_neighbor' was not declared in this scope
   19 |         int nb = find_neighbor(N,i,except);
      |                  ^~~~~~~~~~~~~