Submission #919124

#TimeUsernameProblemLanguageResultExecution timeMemory
919124Mher777게임 (APIO22_game)C++17
60 / 100
4081 ms47248 KiB
#define _CRT_SECURE_NO_WARNINGS #include "game.h" #include <iostream> #include <iomanip> #include <array> #include <string> #include <algorithm> #include <cmath> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <vector> #include <stack> #include <queue> #include <deque> #include <bitset> #include <list> #include <iterator> #include <numeric> #include <complex> #include <utility> #include <random> #include <fstream> using namespace std; /* -------------------- Typedefs -------------------- */ typedef int itn; typedef long long ll; typedef unsigned long long ull; typedef float fl; typedef double db; typedef long double ld; /* -------------------- Usings -------------------- */ using vi = vector<int>; using vll = vector<ll>; using mii = map<int, int>; using mll = map<ll, ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; /* -------------------- Defines -------------------- */ #define ff first #define ss second #define pub push_back #define pob pop_back #define puf push_front #define pof pop_front #define mpr make_pair #define yes cout<<"YES\n" #define no cout<<"NO\n" #define all(x) (x).begin(), (x).end() /* -------------------- Constants -------------------- */ const int MAX = int(2e9 + 5); const ll MAXL = ll(1e18 + 5); const ll MOD = ll(1e9 + 7); const ll MOD2 = ll(998244353); //dp1->maximum gagaty voric karas gas, dp2->minimum gagaty vor hasanelia tvyal gagatic const int max_N = 300005; int n, k; vi g[max_N], g_rev[max_N]; int dp1[max_N], dp2[max_N], used[max_N]; vi nodes; void dfs1(int u) { nodes.pub(u); used[u] = 1; for (auto to : g[u]) { if (!used[to] && dp1[to] < dp1[u]) { dp1[to] = dp1[u]; dfs1(to); } } } void dfs2(int u) { nodes.pub(u); used[u] = 1; for (auto to : g_rev[u]) { if (!used[to] && dp2[to] > dp2[u]) { dp2[to] = dp2[u]; dfs2(to); } } } void init(int N, int K) { n = N, k = K; for (int i = 0; i < k - 1; ++i) { g[i].pub(i + 1); dp1[i] = dp2[i] = i; g_rev[i + 1].pub(i); } dp1[k - 1] = dp2[k - 1] = k - 1; for (int i = k; i < n; ++i) { dp1[i] = -1; dp2[i] = MAX; } } int add_teleporter(int u, int v) { if (dp1[u] >= dp2[v]) return 1; g[u].pub(v); g_rev[v].pub(u); nodes.clear(); dfs1(u); for (auto node : nodes) used[node] = 0; nodes.clear(); dfs2(v); for (auto node : nodes) used[node] = 0; 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...