Submission #1088695

#TimeUsernameProblemLanguageResultExecution timeMemory
1088695Math4Life2020Game (APIO22_game)C++17
2 / 100
1345 ms262144 KiB
#include <bits/stdc++.h> using namespace std; using ll = int; using pii = pair<ll,ll>; ll N,K; const ll INF = 1e9; vector<vector<ll>> f; //forward edges vector<ll> mc; //min color void init(int N1, int K1) { N=N1; K=K1; f.clear(); mc.clear(); for (ll i=0;i<N;i++) { f.push_back(vector<int>(0,0)); mc.push_back(INF); } for (ll k=0;k<K;k++){ mc[k]=k; } } int add_teleporter(int u, int v) { if (u<K && v<K) { if (v<=u) { return 1; } else { return 0; } } if (u==v) { return 0; } f[u].push_back(v); if (mc[u]>=mc[v]) { return 0; } stack<int> s; ll val = mc[u]; s.push(v); while (!s.empty()) { ll x = s.top(); s.pop(); if (x<K) { if (x<=val) { return 1; } } else { if (mc[x]>val) { for (ll y: f[x]) { s.push(y); } } } } 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...