답안 #983793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983793 2024-05-16T06:15:24 Z Kenjikrab 게임 (APIO22_game) C++17
100 / 100
1102 ms 46240 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[u])
      {
        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 14936 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 15092 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 3 ms 14936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 15092 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 3 ms 14936 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 4 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 4 ms 14936 KB Output is correct
12 Correct 3 ms 14936 KB Output is correct
13 Correct 3 ms 14936 KB Output is correct
14 Correct 3 ms 14936 KB Output is correct
15 Correct 4 ms 14936 KB Output is correct
16 Correct 3 ms 14936 KB Output is correct
17 Correct 3 ms 14936 KB Output is correct
18 Correct 4 ms 14936 KB Output is correct
19 Correct 3 ms 14936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 15092 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 3 ms 14936 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 4 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 4 ms 14936 KB Output is correct
12 Correct 3 ms 14936 KB Output is correct
13 Correct 3 ms 14936 KB Output is correct
14 Correct 3 ms 14936 KB Output is correct
15 Correct 4 ms 14936 KB Output is correct
16 Correct 3 ms 14936 KB Output is correct
17 Correct 3 ms 14936 KB Output is correct
18 Correct 4 ms 14936 KB Output is correct
19 Correct 3 ms 14936 KB Output is correct
20 Correct 3 ms 14936 KB Output is correct
21 Correct 4 ms 14936 KB Output is correct
22 Correct 4 ms 14936 KB Output is correct
23 Correct 4 ms 15092 KB Output is correct
24 Correct 5 ms 15192 KB Output is correct
25 Correct 5 ms 15448 KB Output is correct
26 Correct 6 ms 15332 KB Output is correct
27 Correct 6 ms 15192 KB Output is correct
28 Correct 4 ms 14936 KB Output is correct
29 Correct 5 ms 14936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 15092 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 3 ms 14936 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 4 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 4 ms 14936 KB Output is correct
12 Correct 3 ms 14936 KB Output is correct
13 Correct 3 ms 14936 KB Output is correct
14 Correct 3 ms 14936 KB Output is correct
15 Correct 4 ms 14936 KB Output is correct
16 Correct 3 ms 14936 KB Output is correct
17 Correct 3 ms 14936 KB Output is correct
18 Correct 4 ms 14936 KB Output is correct
19 Correct 3 ms 14936 KB Output is correct
20 Correct 3 ms 14936 KB Output is correct
21 Correct 4 ms 14936 KB Output is correct
22 Correct 4 ms 14936 KB Output is correct
23 Correct 4 ms 15092 KB Output is correct
24 Correct 5 ms 15192 KB Output is correct
25 Correct 5 ms 15448 KB Output is correct
26 Correct 6 ms 15332 KB Output is correct
27 Correct 6 ms 15192 KB Output is correct
28 Correct 4 ms 14936 KB Output is correct
29 Correct 5 ms 14936 KB Output is correct
30 Correct 20 ms 16940 KB Output is correct
31 Correct 6 ms 15448 KB Output is correct
32 Correct 20 ms 17500 KB Output is correct
33 Correct 17 ms 16988 KB Output is correct
34 Correct 29 ms 18552 KB Output is correct
35 Correct 34 ms 17628 KB Output is correct
36 Correct 32 ms 17468 KB Output is correct
37 Correct 33 ms 16832 KB Output is correct
38 Correct 27 ms 17460 KB Output is correct
39 Correct 30 ms 16880 KB Output is correct
40 Correct 26 ms 17256 KB Output is correct
41 Correct 37 ms 17628 KB Output is correct
42 Correct 27 ms 16556 KB Output is correct
43 Correct 39 ms 17496 KB Output is correct
44 Correct 35 ms 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14936 KB Output is correct
2 Correct 3 ms 14936 KB Output is correct
3 Correct 3 ms 15092 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 3 ms 14936 KB Output is correct
8 Correct 3 ms 14936 KB Output is correct
9 Correct 4 ms 14936 KB Output is correct
10 Correct 3 ms 14936 KB Output is correct
11 Correct 4 ms 14936 KB Output is correct
12 Correct 3 ms 14936 KB Output is correct
13 Correct 3 ms 14936 KB Output is correct
14 Correct 3 ms 14936 KB Output is correct
15 Correct 4 ms 14936 KB Output is correct
16 Correct 3 ms 14936 KB Output is correct
17 Correct 3 ms 14936 KB Output is correct
18 Correct 4 ms 14936 KB Output is correct
19 Correct 3 ms 14936 KB Output is correct
20 Correct 3 ms 14936 KB Output is correct
21 Correct 4 ms 14936 KB Output is correct
22 Correct 4 ms 14936 KB Output is correct
23 Correct 4 ms 15092 KB Output is correct
24 Correct 5 ms 15192 KB Output is correct
25 Correct 5 ms 15448 KB Output is correct
26 Correct 6 ms 15332 KB Output is correct
27 Correct 6 ms 15192 KB Output is correct
28 Correct 4 ms 14936 KB Output is correct
29 Correct 5 ms 14936 KB Output is correct
30 Correct 20 ms 16940 KB Output is correct
31 Correct 6 ms 15448 KB Output is correct
32 Correct 20 ms 17500 KB Output is correct
33 Correct 17 ms 16988 KB Output is correct
34 Correct 29 ms 18552 KB Output is correct
35 Correct 34 ms 17628 KB Output is correct
36 Correct 32 ms 17468 KB Output is correct
37 Correct 33 ms 16832 KB Output is correct
38 Correct 27 ms 17460 KB Output is correct
39 Correct 30 ms 16880 KB Output is correct
40 Correct 26 ms 17256 KB Output is correct
41 Correct 37 ms 17628 KB Output is correct
42 Correct 27 ms 16556 KB Output is correct
43 Correct 39 ms 17496 KB Output is correct
44 Correct 35 ms 17496 KB Output is correct
45 Correct 202 ms 28516 KB Output is correct
46 Correct 10 ms 17504 KB Output is correct
47 Correct 7 ms 17240 KB Output is correct
48 Correct 305 ms 35828 KB Output is correct
49 Correct 246 ms 36408 KB Output is correct
50 Correct 344 ms 44400 KB Output is correct
51 Correct 591 ms 42888 KB Output is correct
52 Correct 490 ms 35652 KB Output is correct
53 Correct 677 ms 35912 KB Output is correct
54 Correct 624 ms 35576 KB Output is correct
55 Correct 832 ms 35836 KB Output is correct
56 Correct 961 ms 36108 KB Output is correct
57 Correct 394 ms 30272 KB Output is correct
58 Correct 429 ms 29872 KB Output is correct
59 Correct 437 ms 30280 KB Output is correct
60 Correct 384 ms 29756 KB Output is correct
61 Correct 412 ms 29276 KB Output is correct
62 Correct 263 ms 38316 KB Output is correct
63 Correct 196 ms 35080 KB Output is correct
64 Correct 652 ms 46240 KB Output is correct
65 Correct 340 ms 34520 KB Output is correct
66 Correct 274 ms 30772 KB Output is correct
67 Correct 536 ms 38904 KB Output is correct
68 Correct 157 ms 26740 KB Output is correct
69 Correct 42 ms 20504 KB Output is correct
70 Correct 557 ms 37916 KB Output is correct
71 Correct 294 ms 29704 KB Output is correct
72 Correct 192 ms 25008 KB Output is correct
73 Correct 490 ms 33624 KB Output is correct
74 Correct 1102 ms 35620 KB Output is correct
75 Correct 985 ms 37256 KB Output is correct
76 Correct 822 ms 35616 KB Output is correct