답안 #983792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983792 2024-05-16T06:13:56 Z Kenjikrab 게임 (APIO22_game) C++17
2 / 100
4 ms 15196 KB
#include "game.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first 
#define se second
using namespace std;

int const n_max=3e5+10;
int mx[n_max],mn[n_max];
vector<int> node[n_max];
vector<int> rnode[n_max];
int n,k;
void init(int N, int K)
{
  n=N;
  k=K;
  for(int i=1;i<=k;i++)mx[i]=mn[i]=i;
  for(int i=k+1;i<=n;i++)mx[i]=0,mn[i]=k+1;
}
bool flag=false;
int add_teleporter(int uu, int vv)
{
  
  uu++;
  vv++;
  if(flag)return 1;
	if (uu >= vv && uu <= k){flag=true;return 1;}
	if (uu == vv) return 0;
  node[uu].push_back(vv);
  rnode[vv].push_back(uu);
  deque<pii> q;
  q.push_front({uu,vv});
  while(!q.empty())
  {
    int u=q.front().fi,v=q.front().se;
    q.pop_front();
    if(mx[u]>=mn[v])
    {
      flag=true;
      return 1;
    }
    if(mn[u]<=mx[v])
    {
      continue;
    }
    while (mx[u] >= (mn[v] + mx[v]) / 2+1)
    {
      mx[v] = (mx[v] + mn[v]) / 2+1;
      for (auto it:node[v])
      {
        q.push_front({v,it});
      }
    }
    while (mn[v] <= (mn[u] + mx[u]) / 2)
    {
      mn[u] = (mx[u] + mn[u]) / 2 ;
      for (auto it:rnode[v])
      {
        q.push_front({it,u});
      }
    }
	}
  if(flag)return 1;
	return 0;


  /* queue<int> q;
  int val=mx[u];
  if(u<k)val=u;
  if(val==-1)return 0;
  q.push(v);
  while(!q.empty())
  {
    int cur=q.front();
    q.pop();
    if(mx[cur]>=val)continue;
    if(cur<k&&val>=cur)
    {
      flag=true;
      return 1;
    }
    mx[cur]=val;
    for(auto nxt:node[cur])
    {
      if(mx[nxt]>=val)continue;
      q.push(nxt);
    }
  }
  return 0; */
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15188 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 14936 KB Output is correct
4 Correct 3 ms 14936 KB Output is correct
5 Correct 3 ms 14936 KB Output is correct
6 Correct 3 ms 14936 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15188 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 14936 KB Output is correct
4 Correct 3 ms 14936 KB Output is correct
5 Correct 3 ms 14936 KB Output is correct
6 Correct 3 ms 14936 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 3 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14968 KB Output is correct
13 Incorrect 4 ms 14936 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15188 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 14936 KB Output is correct
4 Correct 3 ms 14936 KB Output is correct
5 Correct 3 ms 14936 KB Output is correct
6 Correct 3 ms 14936 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 3 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14968 KB Output is correct
13 Incorrect 4 ms 14936 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15188 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 14936 KB Output is correct
4 Correct 3 ms 14936 KB Output is correct
5 Correct 3 ms 14936 KB Output is correct
6 Correct 3 ms 14936 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 3 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14968 KB Output is correct
13 Incorrect 4 ms 14936 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15188 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 14936 KB Output is correct
4 Correct 3 ms 14936 KB Output is correct
5 Correct 3 ms 14936 KB Output is correct
6 Correct 3 ms 14936 KB Output is correct
7 Correct 4 ms 15196 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 3 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14968 KB Output is correct
13 Incorrect 4 ms 14936 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -