Submission #1088700

#TimeUsernameProblemLanguageResultExecution timeMemory
1088700Math4Life2020Game (APIO22_game)C++17
60 / 100
4096 ms18124 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(); vector<int> vb; for (ll i=0;i<N;i++) { f.push_back(vb); 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; } if (v<K && mc[u]>=v) { return 1; } //cout << "updating u,v="<<u<<","<<v<<"\n"; 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) { //cout << "processD: x="<<x<<"\n"; 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...