제출 #1024697

#제출 시각아이디문제언어결과실행 시간메모리
1024697WansurThousands Islands (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <variant> #define f first #define s second #define ent '\n' using namespace std; typedef long long ll; const int maxn = 2e5 + 12; const int mod = 1e9 + 2022; map<int, int> a[maxn]; vector<int> g[maxn]; int n, m; variant<bool, vector<int>> find_journey(int N, int M, vector<int> u, vector<int> v){ n = N, m = M; for(int i=0;i<m;i++){ a[u[i]][v[i]] = i; g[u[i]].push_back(i); } vector<int> ans; if(g[0].size() >= 2){ int x = v[g[0][0]], y = v[g[0][1]]; ans = {a[0][x], a[x][0], a[0][y], a[y][0], a[x][0], a[0][x], a[y][0], a[0][y]}; return ans; } if(g[0].size() == 0) return false; int x = v[g[0][0]], sz = 1, y = 0; ans = {g[0][0]}; while(g[x].size() == 2){ int t = 0; if(v[g[x][t]] == y){ t++; } ans.push_back(g[x][t]); y = x; x = v[g[x][t]]; } if(g[x].size() <= 1) return false; return {0}; }

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

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:41:14: error: could not convert '{0}' from '<brace-enclosed initializer list>' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   41 |     return {0};
      |              ^
      |              |
      |              <brace-enclosed initializer list>
islands.cpp:29:25: warning: unused variable 'sz' [-Wunused-variable]
   29 |     int x = v[g[0][0]], sz = 1, y = 0;
      |                         ^~