Submission #1058318

#TimeUsernameProblemLanguageResultExecution timeMemory
1058318dozerThousands Islands (IOI22_islands)C++17
10 / 100
22 ms20876 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define sp " " #define endl "\n" #define pii pair<int, int> #define st first #define nd second #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define pb push_back #define LL node * 2 #define RR node * 2 + 1 #define ll long long #define MAXN 300005 const int modulo = 1e9 + 7; const ll INF = 2e18 + 7; vector<pii> in[MAXN], out[MAXN]; variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { for (int i = 0; i < M; i++){ in[V[i]].pb({U[i], i}); out[U[i]].pb({V[i], i}); } if (N == 2){ if (out[0].size() >= 2 && in[0].size() >= 1){ int a = out[0][0].nd, b = out[0][1].nd, c = in[0][0].nd; vector<int> v = {a, c, b, a, c, b}; return v; } return false; } int a = -1, b = -1, c = -1, d = -1; for (auto i : out[0]) { if (i.st == 1) a = i.nd; if (i.st == 2) c = i.nd; } for (auto i : in[0]) { if (i.st == 1) b = i.nd; if (i.st == 2) d = i.nd; } if (a != -1 && b != -1 && c != -1 && d != -1){ vector<int> v = {a, b, c, d, b, a, d, c}; return v; } return false; } /* int main() { fileio(); int N, M; assert(2 == scanf("%d %d", &N, &M)); std::vector<int> U(M), V(M); for (int i = 0; i < M; ++i) { assert(2 == scanf("%d %d", &U[i], &V[i])); } std::variant<bool, std::vector<int>> result = find_journey(N, M, U, V); if (result.index() == 0) { printf("0\n"); if (std::get<bool>(result)) { printf("1\n"); } else { printf("0\n"); } } else { printf("1\n"); std::vector<int> &canoes = std::get<std::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...