답안 #978253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978253 2024-05-09T04:50:52 Z Tsagana 게임 (APIO22_game) C++17
0 / 100
3 ms 14936 KB
#include "game.h"

//OP
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define pi pair<int, int >
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mset multiset
#define F first
#define S second

using namespace std;

struct graph
{
  int n, k;
  vector<int> edge[300005];
  vector<int> adge[300005];
  int min_sp[300005];
  int max_sp[300005];

  void dfs(int s, int ms) {
    if (max_sp[s] >= ms) return ;
    max_sp[s] = ms;
    for (auto i: edge[s]) dfs(i, ms);
  }
  void dfc(int s, int ms) {
    if (min_sp[s] <= ms) return ;
    min_sp[s] = ms;
    for (auto i: adge[s]) dfc(i, ms);
  }
  void add_edge(int u, int v) {
    //cout << u << " -- " << v << '\n';
    edge[u].pb(v);
    adge[v].pb(u);

    if (u < k) dfs(v, max(u, max_sp[u]));
    else dfs(v, max_sp[u]);
    
    if (v < k) dfc(u, min(v, min_sp[v]));
    else dfc(u, min_sp[v]);
  }
  int check_stamp() {
    for (int i = 0; i < n; i++) {
      //cout << i << ' ' << min_sp[i] << ' ' << max_sp[i] << '\n';
      if (min_sp[i] <= max_sp[i]) return 1;
    }
    return 0;
  }
};
graph G;

void init(int n, int k) {
  G.n = n;
  G.k = k;
  for (int i = k-1; i < n; i++) {
    G.min_sp[i] = 1e6;
    G.max_sp[i] = -1;
  }
  for (int i = 0; i < k-1; i++) {
    G.min_sp[i] = i+1;
    G.max_sp[i] = i-1;
    G.add_edge(i, i+1);
  }
}

int add_teleporter(int u, int v) {
  G.add_edge(u, v);
  return G.check_stamp();
}
//ED
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Incorrect 3 ms 14936 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Incorrect 3 ms 14936 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Incorrect 3 ms 14936 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Incorrect 3 ms 14936 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Incorrect 3 ms 14936 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -