제출 #628635

#제출 시각아이디문제언어결과실행 시간메모리
628635dqhungdl수천개의 섬 (IOI22_islands)C++17
5 / 100
36 ms4308 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> using namespace std; variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { if (N == 2) { vector<int> g[2]; for (int i = 0; i < M; i++) g[U[i]].push_back(i); if (g[0].size() < 2 || g[1].size() < 2) return false; return vector<int>({g[0][0], g[1][0], g[0][1], g[1][1], g[1][0], g[0][0], g[1][1], g[0][1]}); } vector<vector<int>> g(N, vector<int>(N, -1)); for (int i = 0; i < M; i++) g[U[i]][V[i]] = i; bool isClique = true; for (int i = 0; i < N && isClique; i++) for (int j = 0; j < N && isClique; j++) if (i != j && g[i][j] == -1) isClique = false; if (isClique) return vector<int>({g[0][1], g[1][2], g[2][0], g[0][2], g[2][1], g[1][0], g[2][0], g[1][2], g[0][1], g[1][0], g[2][1], g[0][2]}); return false; } //int main() { // freopen("../_input", "r", stdin); // int N, M; // assert(2 == scanf("%d %d", &N, &M)); // // vector<int> U(M), V(M); // for (int i = 0; i < M; ++i) { // assert(2 == scanf("%d %d", &U[i], &V[i])); // } // // variant<bool, vector<int>> result = find_journey(N, M, U, V); // if (result.index() == 0) { // printf("0\n"); // if (get<bool>(result)) { // printf("1\n"); // } else { // printf("0\n"); // } // } else { // printf("1\n"); // vector<int> &canoes = get<vector<int>>(result); // printf("%d\n", static_cast<int>(canoes.size())); // for (int i = 0; i < static_cast<int>(canoes.size()); ++i) { // if (i > 0) { // printf(" "); // } // printf("%d", canoes[i]); // } // printf("\n"); // } // return 0; //}
#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...