답안 #599497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599497 2022-07-19T14:39:04 Z DanerZein 게임 (APIO22_game) C++17
60 / 100
4000 ms 43464 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MAX_N=3e5+10;
vector<vi> I;
vector<vi> G;
int fr[MAX_N];
int to[MAX_N];
int K,N;
void init(int n, int k) {
  K=k;
  N=n;
  G.resize(n+1);
  I.resize(n+1);
  for(int i=0;i<=n;i++) fr[i]=1e9;
  memset(to,-1,sizeof to);
}
bool updateG(int u){
  bool ans=0;
  if(to[u]>=fr[u]) return 1;
  for(auto &v:G[u]){
    int val;
    if(u<K) val=u;
    else val=to[u];
    if(to[v]<val){
      to[v]=val;
      ans|=updateG(v);
    }
  }
  return ans;
}
bool updateI(int u){
  bool ans=0;
  if(to[u]>=fr[u]) return 1;
  for(auto &v:I[u]){
    int val;
    if(u<K) val=u;
    else val=fr[u];
    if(val<fr[v]){
      fr[v]=val;
      ans|=updateI(v);
    }
  }
  return ans;
}
int add_teleporter(int u, int v) {
  if(u<K && v<K){
    if(u>=v) return 1;
    return 0;
  }
  G[u].push_back(v);
  I[v].push_back(u);
  if(u<K){
    to[v]=max(to[v],u);
  }
  if(v<K){
    fr[u]=min(fr[u],v);
  }
  /* for(int i=0;i<3;i++)
    cout<<to[i]<<" ";
  cout<<endl;
  for(int i=0;i<3;i++)
    cout<<fr[i]<<" ";
  cout<<endl;*/
  bool s1=updateG(u)|updateG(v);
  bool s2=updateI(v)|updateI(u);
  return s1|s2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 1 ms 1360 KB Output is correct
10 Correct 1 ms 1360 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1488 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1488 KB Output is correct
16 Correct 1 ms 1488 KB Output is correct
17 Correct 1 ms 1488 KB Output is correct
18 Correct 1 ms 1488 KB Output is correct
19 Correct 1 ms 1488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 1 ms 1360 KB Output is correct
10 Correct 1 ms 1360 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1488 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1488 KB Output is correct
16 Correct 1 ms 1488 KB Output is correct
17 Correct 1 ms 1488 KB Output is correct
18 Correct 1 ms 1488 KB Output is correct
19 Correct 1 ms 1488 KB Output is correct
20 Correct 1 ms 1488 KB Output is correct
21 Correct 1 ms 1488 KB Output is correct
22 Correct 1 ms 1488 KB Output is correct
23 Correct 1 ms 1488 KB Output is correct
24 Correct 5 ms 1488 KB Output is correct
25 Correct 5 ms 1616 KB Output is correct
26 Correct 3 ms 1616 KB Output is correct
27 Correct 3 ms 1576 KB Output is correct
28 Correct 3 ms 1488 KB Output is correct
29 Correct 2 ms 1488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 1 ms 1360 KB Output is correct
10 Correct 1 ms 1360 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1488 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1488 KB Output is correct
16 Correct 1 ms 1488 KB Output is correct
17 Correct 1 ms 1488 KB Output is correct
18 Correct 1 ms 1488 KB Output is correct
19 Correct 1 ms 1488 KB Output is correct
20 Correct 1 ms 1488 KB Output is correct
21 Correct 1 ms 1488 KB Output is correct
22 Correct 1 ms 1488 KB Output is correct
23 Correct 1 ms 1488 KB Output is correct
24 Correct 5 ms 1488 KB Output is correct
25 Correct 5 ms 1616 KB Output is correct
26 Correct 3 ms 1616 KB Output is correct
27 Correct 3 ms 1576 KB Output is correct
28 Correct 3 ms 1488 KB Output is correct
29 Correct 2 ms 1488 KB Output is correct
30 Correct 24 ms 4100 KB Output is correct
31 Correct 6 ms 3392 KB Output is correct
32 Correct 29 ms 5180 KB Output is correct
33 Correct 17 ms 4888 KB Output is correct
34 Correct 1425 ms 6764 KB Output is correct
35 Correct 410 ms 5580 KB Output is correct
36 Correct 35 ms 4936 KB Output is correct
37 Correct 29 ms 4872 KB Output is correct
38 Correct 31 ms 4640 KB Output is correct
39 Correct 32 ms 4568 KB Output is correct
40 Correct 903 ms 6692 KB Output is correct
41 Correct 172 ms 5064 KB Output is correct
42 Correct 113 ms 4976 KB Output is correct
43 Correct 48 ms 5936 KB Output is correct
44 Correct 770 ms 6680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1360 KB Output is correct
7 Correct 1 ms 1360 KB Output is correct
8 Correct 1 ms 1360 KB Output is correct
9 Correct 1 ms 1360 KB Output is correct
10 Correct 1 ms 1360 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1488 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1360 KB Output is correct
15 Correct 1 ms 1488 KB Output is correct
16 Correct 1 ms 1488 KB Output is correct
17 Correct 1 ms 1488 KB Output is correct
18 Correct 1 ms 1488 KB Output is correct
19 Correct 1 ms 1488 KB Output is correct
20 Correct 1 ms 1488 KB Output is correct
21 Correct 1 ms 1488 KB Output is correct
22 Correct 1 ms 1488 KB Output is correct
23 Correct 1 ms 1488 KB Output is correct
24 Correct 5 ms 1488 KB Output is correct
25 Correct 5 ms 1616 KB Output is correct
26 Correct 3 ms 1616 KB Output is correct
27 Correct 3 ms 1576 KB Output is correct
28 Correct 3 ms 1488 KB Output is correct
29 Correct 2 ms 1488 KB Output is correct
30 Correct 24 ms 4100 KB Output is correct
31 Correct 6 ms 3392 KB Output is correct
32 Correct 29 ms 5180 KB Output is correct
33 Correct 17 ms 4888 KB Output is correct
34 Correct 1425 ms 6764 KB Output is correct
35 Correct 410 ms 5580 KB Output is correct
36 Correct 35 ms 4936 KB Output is correct
37 Correct 29 ms 4872 KB Output is correct
38 Correct 31 ms 4640 KB Output is correct
39 Correct 32 ms 4568 KB Output is correct
40 Correct 903 ms 6692 KB Output is correct
41 Correct 172 ms 5064 KB Output is correct
42 Correct 113 ms 4976 KB Output is correct
43 Correct 48 ms 5936 KB Output is correct
44 Correct 770 ms 6680 KB Output is correct
45 Correct 295 ms 28004 KB Output is correct
46 Correct 16 ms 17104 KB Output is correct
47 Correct 14 ms 17024 KB Output is correct
48 Correct 407 ms 43464 KB Output is correct
49 Correct 360 ms 35616 KB Output is correct
50 Execution timed out 4032 ms 35516 KB Time limit exceeded
51 Halted 0 ms 0 KB -