답안 #836288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836288 2023-08-24T09:47:10 Z KALARRY Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

int ans;
vector<int> adj[520];
int scores[520];
int target,temp;
vector<int> queries;


void dfs(int v,int p)
{
    temp -= scores[v];
    queries.push_back(v);
    if(temp==0)
        return;
    for(auto u : adj[v])
        if(u!=p)
            dfs(u,v);
}

int findEgg(int N,vector<pair<int,int>> bridges)
{
    for(auto e : bridges)
    {
        int a = e.first;
        int b = e.second;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1 ; i <= N ; i++)
       scores[i] = 1;
    target = N;
    while(target>1)
    {
        queries.clear();
        target/=2;
        temp = target;
        dfs(1,1);
        int res = query(queries);
        if(res==0)
            for(auto u : queries)
                scores[u] = 0;
        else
        {
            for(auto u : queries)
                scores[u]++;
            for(int i = 1 ; i <= N ; i++)
            {
                if(scores[i]==1)
                    scores[i] = 0;
                if(scores[i]==2)
                    scores[i] = 1;
            }
        }
    }
    int egg = -1;
    for(int i = 1 ; i <= N ; i++)
        if(scores[i]==1)
            egg = i;
    return egg;    
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:43:19: error: 'query' was not declared in this scope; did you mean 'queries'?
   43 |         int res = query(queries);
      |                   ^~~~~
      |                   queries