Submission #1189841

#TimeUsernameProblemLanguageResultExecution timeMemory
1189841Panda50OEaster Eggs (info1cup17_eastereggs)C++20
Compilation error
0 ms0 KiB
#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 (stderr)

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;
      |     ~~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccOiMBU5.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/ccqUSVyi.o:eastereggs.cpp:(.text+0x50): first defined here
/usr/bin/ld: /tmp/ccOiMBU5.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqUSVyi.o:eastereggs.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqUSVyi.o: in function `main':
eastereggs.cpp:(.text.startup+0x254): undefined reference to `findEgg(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
/usr/bin/ld: /tmp/ccOiMBU5.o: in function `main':
grader.cpp:(.text.startup+0x1e7): undefined reference to `findEgg(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
collect2: error: ld returned 1 exit status