Submission #707641

#TimeUsernameProblemLanguageResultExecution timeMemory
707641600MihneaGame (APIO22_game)C++17
60 / 100
4070 ms41360 KiB
#include "game.h" #include <cmath> #include <functional> #include <fstream> #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <map> #include <list> #include <time.h> #include <math.h> #include <random> #include <deque> #include <queue> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <cassert> #include <bitset> #include <sstream> #include <chrono> #include <cstring> #include <numeric> using namespace std; const int INF = (int)1e9 + 7; int rad; int getbucket(int a) { return a / rad; } int n, k; vector<vector<int>> g, ig; vector<int> mn, mnbu; vector<int> precis; bool is; void addedge(int from, int to) { g[from].push_back(to); ig[to].push_back(from); } void init(int nn, int kk) { is = 0; n = nn; k = kk; rad = sqrt(n) + 2; g.clear(); g.resize(n); ig.clear(); ig.resize(n); mn.clear(); mn.resize(n, +INF); mnbu.clear(); mnbu.resize(n, +INF); precis.clear(); precis.resize(n, 0); } void upd(int a, int b) { if (is) { return; } if (b < k) { if (b < mn[a]) { mn[a] = b; if (a < k && mn[a] <= a) { is = 1; return; } for (auto& b : ig[a]) { upd(b, mn[a]); } } return; } if (mn[b] < mn[a]) { mn[a] = mn[b]; if (a < k && mn[a] <= a) { is = 1; return; } for (auto& b : ig[a]) { upd(b, mn[a]); } } } int add_teleporter(int from, int to) { addedge(from, to); if (to < k) { upd(from, to); } else { upd(from, to); } if (is) { return 1; } 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...