답안 #319597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319597 2020-11-05T16:40:55 Z tasfiq4 Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

static int N, X, cntQ;
static vector < int > v[1009];

int query (vector < int > h)
{
    cntQ ++;
    int ap[1009];
    if (h.empty ()) return 0;
    for (int i=1; i<=N; i++)
        ap[i] = 0;
    for (auto it = h.begin (); it != h.end (); it ++)
        ap[*it] = 1;
    queue < int > cc;
    cc.push (h[0]), ap[h[0]] = 2;
    while (!cc.empty ())
    {
        int nod = cc.front ();
        cc.pop ();
        for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
            if (ap[*it] == 1)
                ap[*it] = 2, cc.push (*it);
    }
    for (int i=1; i<=N; i++)
        if (ap[i] == 1) return -1;
    for (auto it = h.begin (); it != h.end (); it ++)
        if (*it == X) return 1;
    return 0;
}

int main ()
{
freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
int Queries;
vector < pair < int, int > > param;
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
    param.push_back ({x, y});
}
scanf ("%d", &Queries);
while (Queries --)
{
    scanf ("%d", &X), cntQ = 0;
    int Y = findEgg (N, param);
    if (X != Y)
    {
        printf ("WA %d instead of %d\n", Y, X);
        return 0;
    }
    printf ("OK %d\n", cntQ);
}
return 0;
}

Compilation message

eastereggs.cpp: In function 'int main()':
eastereggs.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   37 | freopen ("input", "r", stdin);
      | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
eastereggs.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 | scanf ("%d", &N);
      | ~~~~~~^~~~~~~~~~
eastereggs.cpp:46:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |     scanf ("%d %d", &x, &y);
      |     ~~~~~~^~~~~~~~~~~~~~~~~
eastereggs.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 | scanf ("%d", &Queries);
      | ~~~~~~^~~~~~~~~~~~~~~~
eastereggs.cpp:54:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   54 |     scanf ("%d", &X), cntQ = 0;
      |     ~~~~~~^~~~~~~~~~
/tmp/ccH3cyiJ.o: In function `query(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `query(std::vector<int, std::allocator<int> >)'
/tmp/cccn0jLO.o:eastereggs.cpp:(.text+0x40): first defined here
/tmp/ccH3cyiJ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cccn0jLO.o:eastereggs.cpp:(.text.startup+0x0): first defined here
/tmp/cccn0jLO.o: In function `main':
eastereggs.cpp:(.text.startup+0x253): undefined reference to `findEgg(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
/tmp/ccH3cyiJ.o: In function `main':
grader.cpp:(.text.startup+0x1e1): undefined reference to `findEgg(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
collect2: error: ld returned 1 exit status