제출 #1028236

#제출 시각아이디문제언어결과실행 시간메모리
102823642kangaroo수천개의 섬 (IOI22_islands)C++17
10 / 100
20 ms5328 KiB
#include "islands.h" #include <variant> #include <vector> #include "bits/stdc++.h" using namespace std; using g_t = vector<vector<pair<int,int>>>; int dfs(int n, int p, g_t& g, vector<bool>& vis, vector<int>& re) { vis[n] = true; for (auto [ne, nu]: g[n]) { if (vis[ne]) { re.push_back(nu); return ne; } int res = dfs(ne, nu, g, vis, re); if (re.empty()) continue; re.push_back(nu); if (res == n) { re.push_back(-1); return -2; } return res; } return -2; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { if (N == 2) { vector<int> s0, s1; for (int i = 0; i < M; ++i) { if (U[i] == 0) s0.push_back(i); else s1.push_back(i); } if (s0.size() >= 2 && s1.size() >= 1) { return vector<int>{s0[0], s1[0], s0[1], s0[0], s1[0], s0[1]}; } else return false; } g_t g(N); int s01, s10, s21, s02; for (int i = 0; i < M; ++i) { if (U[i] == 0 && V[i] == 1) s01 = i; if (U[i] == 1 && V[i] == 0) s10 = i; if (U[i] == 2 && V[i] == 1) s21 = i; if (U[i] == 0 && V[i] == 2) s02 = i; } return vector<int>{s02, s21, s10, s01, s21, s02, s10, s01}; }

컴파일 시 표준 에러 (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:50:59: warning: 's02' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |  return vector<int>{s02, s21, s10, s01, s21, s02, s10, s01};
      |                                                           ^
islands.cpp:50:59: warning: 's21' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:50:59: warning: 's10' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:50:59: warning: 's01' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...