답안 #912561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912561 2024-01-19T15:46:57 Z efedmrlr 게임 (APIO22_game) C++17
60 / 100
4000 ms 41196 KB
#include "game.h"

// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;


#define lli long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


const double EPS = 0.00001;
const int INF = 1e9+500;
const int ALPH = 26;
const int LGN = 25;
constexpr int MOD = 1e9+7;
int N,K;
vector<vector<int> > adj, adjt;
vector<int> vis;
int timer = 1;
vector<int> arr, arrt;
bool dfs(int node, int val) {
  vis[node] = timer;
  
  if(val <= arr[node]) {
    return 0;
  }
  arr[node] = val;
  if(arr[node] >= arrt[node] && node > K) {
    return 1;
  }
  for(auto c : adj[node]) {
    if(vis[c] == timer) continue;
    if(dfs(c, val)) return 1;
  }
  return 0;
}

bool dfst(int node, int val) {
  vis[node] = timer;
  if(arr[node] >= arrt[node] && node > K) {
    return 1;
  }
  if(val >= arrt[node]) {
    return 0;
  }
  arrt[node] = val;
  if(arr[node] >= arrt[node] && node > K) {
    return 1;
  }
  for(auto c : adjt[node]) {
    if(vis[c] == timer) continue;
    if(dfst(c, val)) return 1;
  }
  return 0;
}


void init(int n, int k) {
  N = n; K = k;
  adj.resize(n + 3, vector<int>());
  adjt.resize(n + 3, vector<int>());
  vis.assign(n + 3, 0);
  arr.assign(n + 3, 0);
  arrt.assign(n + 3, INF);
  for(int i = 1; i<=k; i++) {
    arr[i] = i; arrt[i] = i;
  }

}

int add_teleporter(int u, int v) {
  u++; v++;
  if(u <= K && v <= K) {
    if(u >= v) return 1;
    return 0; 
  }

  if(dfs(v, arr[u])) return 1;
  timer++;
  if(dfst(u, arrt[v])) return 1;
  timer++;
  adj[u].pb(v);
  adjt[v].pb(u);
  return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 616 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 672 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 552 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 616 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 672 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 552 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 13 ms 3632 KB Output is correct
31 Correct 4 ms 2648 KB Output is correct
32 Correct 14 ms 4900 KB Output is correct
33 Correct 12 ms 4124 KB Output is correct
34 Correct 925 ms 5284 KB Output is correct
35 Correct 332 ms 4848 KB Output is correct
36 Correct 26 ms 4784 KB Output is correct
37 Correct 30 ms 4712 KB Output is correct
38 Correct 19 ms 4168 KB Output is correct
39 Correct 21 ms 4464 KB Output is correct
40 Correct 821 ms 5440 KB Output is correct
41 Correct 142 ms 4424 KB Output is correct
42 Correct 92 ms 4676 KB Output is correct
43 Correct 28 ms 4660 KB Output is correct
44 Correct 679 ms 5268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 616 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 672 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 3 ms 552 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 13 ms 3632 KB Output is correct
31 Correct 4 ms 2648 KB Output is correct
32 Correct 14 ms 4900 KB Output is correct
33 Correct 12 ms 4124 KB Output is correct
34 Correct 925 ms 5284 KB Output is correct
35 Correct 332 ms 4848 KB Output is correct
36 Correct 26 ms 4784 KB Output is correct
37 Correct 30 ms 4712 KB Output is correct
38 Correct 19 ms 4168 KB Output is correct
39 Correct 21 ms 4464 KB Output is correct
40 Correct 821 ms 5440 KB Output is correct
41 Correct 142 ms 4424 KB Output is correct
42 Correct 92 ms 4676 KB Output is correct
43 Correct 28 ms 4660 KB Output is correct
44 Correct 679 ms 5268 KB Output is correct
45 Correct 204 ms 30328 KB Output is correct
46 Correct 12 ms 18264 KB Output is correct
47 Correct 11 ms 18776 KB Output is correct
48 Correct 360 ms 41196 KB Output is correct
49 Correct 280 ms 37132 KB Output is correct
50 Execution timed out 4077 ms 32320 KB Time limit exceeded
51 Halted 0 ms 0 KB -