Submission #1051196

#TimeUsernameProblemLanguageResultExecution timeMemory
1051196Trent수천개의 섬 (IOI22_islands)C++17
0 / 100
19 ms7636 KiB
#include "islands.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;

struct edge{int t, i;};
vector<vector<edge>> adj;
std::variant<bool, std::vector<int>> find_journey(
    int N, int M, std::vector<int> U, std::vector<int> V) {
      adj.resize(N);
      forR(i, M) {
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
      }
      if(N == 2) {
        if(adj[0].size() < 2 || adj[1].size() < 1) return false;
        else {
          return vector<int> {adj[0][0].i, adj[1][0].i, adj[0][1].i, adj[0][0].i, adj[1][0].i, adj[0][1].i};
        }
      } else {
        int ab, ba, ac, ca;
        forR(i, M) {
          if(U[i] == 0 && V[i] == 1) ab = i;
          else if(U[i] == 1 && V[i] == 0) ba = i;
          else if(U[i] == 0 && V[i] == 2) ac = i;
          else if(U[i] == 2 && V[i] == 0) ca = i;
        }
        return vector<int> {ab, ba, ac, ca, ba, ab, ca, ac};
      }
}

Compilation message (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:35:59: warning: 'ca' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |         return vector<int> {ab, ba, ac, ca, ba, ab, ca, ac};
      |                                                           ^
islands.cpp:35:59: warning: 'ac' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:59: warning: 'ba' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:59: warning: 'ab' 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...