Submission #1284825

#TimeUsernameProblemLanguageResultExecution timeMemory
1284825Muhammad_AneeqIsland Hopping (JOI24_island)C++20
Compilation error
0 ms0 KiB
#include "island.h" #include "iostream" using namespace std; void solve(int N, int L) { vector<int>z; vector<pair<int,int>>ed; int P[N+10]={0}; P[N]=-1; bool vis[N+10]={}; int g=query(N,1); P[g]=N; ed.push_back({N,g}); int y=query(g,1); vis[N]=1; if (y!=N) { ed.push_back({y,g}); P[y]=g; vis[g]=1; z.push_back(y); for (auto i:z) { vis[i]=1; int f=query(i,1); if (f==P[i]) { f=query(i,2); if (vis[f]) break; } ed.push_back({i,f}); P[f]=i; z.push_back(f); } } y=query(N,2); if(!vis[y]) { z={}; ed.push_back({y,N}); P[y]=N; vis[N]=1; z.push_back(y); for (auto i:z) { vis[i]=1; int f=query(i,1); if (f==P[i]) { f=query(i,2); if (vis[f]) break; } ed.push_back({i,f}); P[f]=i; z.push_back(f); } } for (auto [i,j]:ed) answer(i,j); }

Compilation message (stderr)

island.cpp: In function 'void solve(int, int)':
island.cpp:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int>z;
      |     ^~~~~~
island.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include "iostream"
  +++ |+#include <vector>
    3 | using namespace std;
island.cpp:6:12: error: expected primary-expression before 'int'
    6 |     vector<int>z;
      |            ^~~
island.cpp:7:24: error: expected primary-expression before '>' token
    7 |     vector<pair<int,int>>ed;
      |                        ^~
island.cpp:7:26: error: 'ed' was not declared in this scope
    7 |     vector<pair<int,int>>ed;
      |                          ^~
island.cpp:21:9: error: 'z' was not declared in this scope
   21 |         z.push_back(y);
      |         ^
island.cpp:40:9: error: 'z' was not declared in this scope
   40 |         z={};
      |         ^