제출 #709359

#제출 시각아이디문제언어결과실행 시간메모리
709359600MihneaGame (APIO22_game)C++17
2 / 100
1 ms208 KiB
#include <cstdio> #include <cstdlib> #include <vector> #include "game.h" #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 <bitset> #include <cassert> #include <sstream> #include <chrono> #include <cstring> #include <numeric> using namespace std; int n; int k; vector<int> mn; vector<int> mx; vector<vector<int>> g; vector<vector<int>> ig; void init(int nn, int kk) { n = nn; k = kk; mn.clear(); mx.clear(); g.clear(); ig.clear(); mn.resize(n + 1); mx.resize(n + 1); g.resize(n + 1); ig.resize(n + 1); for (int i = 1; i <= n; i++) { mx[i] = -1; mn[i] = k + 1; } for (int i = 1; i <= k; i++) { mn[i] = i; } } bool check(int from, int to) { if (mn[to] <= mx[from]) return 1; if (mn[to] < mn[from]) { mn[from] = mn[to]; for (auto& vec : ig[from]) { if (check(vec, from)) { return 1; } } } if (mx[from] > mx[to]) { mx[to] = mx[from]; for (auto& vec : g[to]) { if (check(vec, to)) { return 1; } } } return 0; } int add_teleporter(int from, int to) { from++; to++; assert(1 <= from && from <= n); assert(1 <= to && to <= n); if (from == to) { if (from <= k) { return 1; } else { return 0; } } if (to < from && from <= k) { return 1; } if (to <= k) { mn[from] = min(mn[from], to); } if (from <= k) { mx[to] = max(mx[to], from); } bool ok = check(from, to); //for (int i = 1; i <= n; i++) //{ // cout << i << " : " << mn[i] << ", " << mx[i] << "\n"; //} return ok; }
#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...