답안 #576826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576826 2022-06-13T15:27:18 Z Omar_Elgedawy 게임 (APIO22_game) C++17
12 / 100
4000 ms 1292 KB
#include <bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
#define cin(vec)        for(auto& i : vec) cin >> i
#define cout(vec)       for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast            ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b)     for (int i = a; i < b; i++)
#define F               first
#define S               second
#define pb(n)           push_back(n)
#define pf(n)           push_front(n)
#define dci(d)          fixed<<setprecision(d)
#define sp              ' '
#define el              '\n'
#define all(v)          v.begin(),v.end()
int const N=30005;
int n,k,vis[N],vid;
vector<int>g[N];
void dfs(int u,int dpth){
  if(dpth)
    vis[u]=vid;
  for(auto u:g[u]){
    if(vis[u]!=vid){
      vis[u]=vid;
      dfs(u,dpth+1);
    }
  }
}
void init(int _n, int _k) {
  n=_n;k=_k;
  for(int i=0;i<k-1;i++)g[i].pb(i+1);
}
int add_teleporter(int u, int v) {
  if(u<k&&v<k){
    if(v<=u)return 1;
  }
  else if(u==v){
  }
  else{
    g[u].pb(v);
    int c=0;
    for(int i=0;i<k;i++){
      vid++;
      dfs(i,0);
      if(vis[i]==vid)return 1;
      // cout<<i<<' '<<vis[i]<<' '<<vid<<el;
    }
    // cout<<el;
  }
  return 0;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:41:9: warning: unused variable 'c' [-Wunused-variable]
   41 |     int c=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 948 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1012 KB Output is correct
12 Correct 1 ms 976 KB Output is correct
13 Correct 1 ms 976 KB Output is correct
14 Correct 2 ms 976 KB Output is correct
15 Correct 2 ms 976 KB Output is correct
16 Correct 1 ms 976 KB Output is correct
17 Correct 6 ms 976 KB Output is correct
18 Correct 2 ms 976 KB Output is correct
19 Correct 2 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 948 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1012 KB Output is correct
12 Correct 1 ms 976 KB Output is correct
13 Correct 1 ms 976 KB Output is correct
14 Correct 2 ms 976 KB Output is correct
15 Correct 2 ms 976 KB Output is correct
16 Correct 1 ms 976 KB Output is correct
17 Correct 6 ms 976 KB Output is correct
18 Correct 2 ms 976 KB Output is correct
19 Correct 2 ms 976 KB Output is correct
20 Correct 3 ms 976 KB Output is correct
21 Correct 5 ms 976 KB Output is correct
22 Correct 34 ms 1028 KB Output is correct
23 Correct 3 ms 976 KB Output is correct
24 Correct 1099 ms 1292 KB Output is correct
25 Correct 3572 ms 1144 KB Output is correct
26 Correct 3119 ms 1044 KB Output is correct
27 Execution timed out 4091 ms 1044 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 948 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1012 KB Output is correct
12 Correct 1 ms 976 KB Output is correct
13 Correct 1 ms 976 KB Output is correct
14 Correct 2 ms 976 KB Output is correct
15 Correct 2 ms 976 KB Output is correct
16 Correct 1 ms 976 KB Output is correct
17 Correct 6 ms 976 KB Output is correct
18 Correct 2 ms 976 KB Output is correct
19 Correct 2 ms 976 KB Output is correct
20 Correct 3 ms 976 KB Output is correct
21 Correct 5 ms 976 KB Output is correct
22 Correct 34 ms 1028 KB Output is correct
23 Correct 3 ms 976 KB Output is correct
24 Correct 1099 ms 1292 KB Output is correct
25 Correct 3572 ms 1144 KB Output is correct
26 Correct 3119 ms 1044 KB Output is correct
27 Execution timed out 4091 ms 1044 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 976 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 948 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1012 KB Output is correct
12 Correct 1 ms 976 KB Output is correct
13 Correct 1 ms 976 KB Output is correct
14 Correct 2 ms 976 KB Output is correct
15 Correct 2 ms 976 KB Output is correct
16 Correct 1 ms 976 KB Output is correct
17 Correct 6 ms 976 KB Output is correct
18 Correct 2 ms 976 KB Output is correct
19 Correct 2 ms 976 KB Output is correct
20 Correct 3 ms 976 KB Output is correct
21 Correct 5 ms 976 KB Output is correct
22 Correct 34 ms 1028 KB Output is correct
23 Correct 3 ms 976 KB Output is correct
24 Correct 1099 ms 1292 KB Output is correct
25 Correct 3572 ms 1144 KB Output is correct
26 Correct 3119 ms 1044 KB Output is correct
27 Execution timed out 4091 ms 1044 KB Time limit exceeded
28 Halted 0 ms 0 KB -