제출 #971062

#제출 시각아이디문제언어결과실행 시간메모리
971062ALeonidou수천개의 섬 (IOI22_islands)C++17
6.75 / 100
24 ms5212 KiB
#include "islands.h" #include <set> #include <variant> #include <vector> #include <iostream> using namespace std; #define ll int #define F first #define S second #define pb push_back #define sz(x) (ll)x.size() #define endl "\n" typedef vector <ll> vi; typedef pair <ll, ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } ll n,m; vi u,v; variant<bool, vi> find_journey(int N, int M, vi U, vi V){ ll n = N, m = M; u = U, v = V; // printVct(u); // printVct(v); if (n == 2){ ll f0 = 0, f1= 0; vi a(3,-1); for (ll i =0; i<m; i++){ if (!u[i]){ f0++; if (a[0] == -1){ a[0] = i; } else if (a[1] == -1){ a[1] = i; } } else{ f1++; if (a[2] == -1){ a[2] = i; } } } // dbg2(f0, f1); // printVct(a); if (f0 >= 2 && f1 >= 1){ return vi({a[0], a[2], a[1], a[0], a[2], a[1]}); } else{ return false; } } else{ //subtask 2: set <ll> st; vii a; //with boat S you go from 0 to F for (ll i =0; i<m; i++){ if (u[i] == 0 && st.find(v[i]) == st.end()){ st.insert(v[i]); a.pb(ii(v[i], i)); } if (sz(a) >= 2) break; } // dbg(sz(a)); if (sz(a) < 2) return false; vi b = vi({-1, a[0].S, a[1].S, -1}); for (ll i =0; i<n; i++){ if (u[i] == a[0].F && v[i] == 0){ b[0] = i; } } for (ll i =0; i<n; i++){ if (u[i] == a[1].F && v[i] == 0){ b[3] = i; } } // printVct(b); return vi({b[1], b[0], b[2], b[3], b[0], b[1], b[3], b[2]}); } return false; } /* 3 4 0 1 1 0 2 0 0 2 2 3 0 1 1 0 1 0 2 3 0 1 0 1 1 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...