제출 #1084490

#제출 시각아이디문제언어결과실행 시간메모리
1084490SamueleVid수천개의 섬 (IOI22_islands)C++17
10 / 100
21 ms5980 KiB
#include <bits/stdc++.h>
using namespace std;

variant<bool, vector<int>> n_two(int N, int M, vector<int> U, vector<int> V) {
    vector<int> el_primo;
    vector<int> el_secondo;
    for (int i = 0; i < M; i ++) {
        if (U[i] == 0) el_primo.push_back(i);
        if (U[i] == 1) el_secondo.push_back(i);
    }

    if (el_primo.size() >= 2 && el_secondo.size() >= 1) {
        int a = el_primo[0];
        int b = el_secondo[0];
        int c = el_primo[1];
        vector<int> res = {a, b, c, a, b, c};
        return res;
    }

    return false;
}

variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
    if (N <= 2) return n_two(N, M, U, V);

    int a, b, c, d, e, f;
        for (int i = 0; i < M; i ++) {
        if (U[i] == 0 && V[i] == 1) a = i;
        if (U[i] == 1 && V[i] == 0) b = i;
        if (U[i] == 1 && V[i] == 2) c = i;
        if (U[i] == 2 && V[i] == 1) d = i;
        if (U[i] == 2 && V[i] == 0) e = i;
        if (U[i] == 0 && V[i] == 2) f = i;
    }

    vector<int> res = {a, c, e, f, d, b, e, c, a, b, d, f};
    return res;
}

컴파일 시 표준 에러 (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:36:58: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     vector<int> res = {a, c, e, f, d, b, e, c, a, b, d, f};
      |                                                          ^
islands.cpp:36:58: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:36:58: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:36:58: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:36:58: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:36:58: warning: 'a' 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...