제출 #1196381

#제출 시각아이디문제언어결과실행 시간메모리
1196381anmattroi게임 (APIO22_game)C++17
0 / 100
4 ms8768 KiB
#include "game.h" #include <bits/stdc++.h> #define maxn 300005 using namespace std; int n, k; int cl[30005][1005]; vector<int> adj[maxn]; map<int, int> cached[30005]; void init(int n, int k) { ::n = n; ::k = k; for (int i = 0; i < k-1; i++) adj[i].emplace_back(i+1); for (int i = 0; i < k; i++) for (int j = 0; j <= i; j++) cl[i][j] = 1; } int add_teleporter(int u, int v) { if (u == v && u < k) return 1; if (u < k && v < k && v <= u) return 1; if (!cached[u].count(v)) adj[u].emplace_back(v); else return 0; cached[u][v] = 1; for (int o = 0; o < k; o++) if ((o == u || cl[u][o]) && !cl[v][o]) { queue<int> q; q.emplace(v); cl[v][o] = 1; while (!q.empty()) { int x = q.front(); q.pop(); for (int y : adj[x]) { if (y <= o) return 1; if (!cl[y][o]) { cl[y][o] = 1; q.emplace(y); } } } } return 0; } /* 4 3 2 1 3 2 0 3 2 2 */
#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...