# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
974554 | 2024-05-03T13:03:17 Z | IUA_Hasin | 게임 (APIO22_game) | C++17 | 0 ms | 0 KB |
#include "game.h" #include <bits\stdc++.h> #define endl "\n" #define ll long long using namespace std; const ll N = 3e5+10; ll NN, K; std::vector<ll> graph[N]; ll vis[N]; ll vis2[N]; std::vector<ll> nodes; std::vector<ll> dfs(ll source){ if(vis[source]==0){ vis[source] = 1; nodes.push_back(source); for(auto u : graph[source]){ dfs(u); } } else { return nodes; } return nodes; } void init(int n, int k) { NN = n; K = k; for(int i=0; i<=k-2; i++){ graph[i].push_back(i+1); } } int add_teleporter(int u, int v) { graph[u].push_back(v); for(int i=0; i<NN; i++){ vis[i] = 0; } nodes.clear(); if(u>=K && v<K){ vis2[u] = 1; } if(u<K && v<K){ return 1; } else { std::vector<ll> v = dfs(0); for(int i=0; i<v.size(); i++){ cout << v[i] << " "; } cout<<endl; ll status = 0; for(int i=0; i<v.size(); i++){ if(status==1){ break; } else { ll a = v[i]; if(vis2[i]==1){ status = 1; } } } return status; } }