답안 #700230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700230 2023-02-19T01:54:18 Z cig32 Amusement Park (JOI17_amusement_park) C++17
83 / 100
26 ms 4868 KB
#include "Joi.h"
#include "bits/stdc++.h"
using namespace std;

static vector<int> adj2[12269];
static bool vis2[12269];
static int val2[12269];
static int nxt2;
static void dfs2(int node, long long X, int par) {
  val2[node] = nxt2;
  nxt2 = (nxt2 + 1) % 60;
  long long res = (X & (1ll << val2[node]));
  if(res > 0) res = 1;
  MessageBoard(node, (int) res);
  vis2[node] = 1;
  for(int x: adj2[node]) {
    if(!vis2[x]) {
      dfs2(x, X, node);
    }
  }
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
  for(int i=0; i<M; i++) {
    adj2[A[i]].push_back(B[i]);
    adj2[B[i]].push_back(A[i]);
  }
  for(int i=0; i<N; i++) {
    sort(adj2[i].begin(), adj2[i].end());
  }
  for(int i=0; i<N; i++) {
    vis2[i] = 0;
  }
  dfs2(0, X, -1);
}
#include "Ioi.h"
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e4 + 10;
static vector<int> adj[MAXN];
static bool vis[MAXN];
static int val[MAXN];
static int sz[MAXN];
static int nxt;
static vector<int> et;
static int p[MAXN];
static void dfs(int node, int par) {
  val[node] = nxt;
  nxt = (nxt+1) % 60;
  vis[node] = 1;
  sz[node] = 1;
  p[node] = par;
  et.push_back(node);
  for(int x: adj[node]) {
    if(!vis[x]) {
      dfs(x, node);
      et.push_back(node);
      sz[node] += sz[x];
    }
  }
}
 
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  nxt = 0;
  et.clear();
  for(int i=0; i<N; i++) {
    adj[i].clear();
  }
  for(int i=0; i<M; i++) {
    adj[A[i]].push_back(B[i]);
    adj[B[i]].push_back(A[i]);
  }
  for(int i=0; i<N; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  for(int i=0; i<N; i++) {
    vis[i] = 0;
  }
  dfs(0, -1);
  long long ans = 0;
  int res[60];
  for(int i=0; i<60; i++) res[i] = -1;
  res[val[P]] = V;
  int l[N];
  for(int i=0; i<N; i++) l[i] = -1;
  for(int i=0; i<et.size(); i++) {
    if(l[et[i]] == -1) l[et[i]] = i;
  }
  int node = P, idx = l[P];
  
  if(sz[node]>=60) {
    set<int> st;
    st.insert(val[P]);
    while(st.size() != 60) {
      idx++;
      node = et[idx];
      res[val[node]] = Move(node);
      st.insert(val[node]);
    }
  }
  else {
    set<int>st;
    st.insert(val[P]);
    for(int i=0; sz[node]<min(90, N); i++) {
      if(p[node] != -1) {
        node=p[node];
        idx=l[node];
        res[val[node]]=Move(node);
        st.insert(val[node]);
      }
      else break;
    }
    while(st.size() != 60) {
      idx++;
      idx %= (int) et.size();
      node = et[idx];
      res[val[node]] = Move(node);
      st.insert(val[node]);
    }
 
  }
 
  for(int i=0; i<60; i++) {
    if(res[i]) ans += (1ll << i);
  }
  return ans;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:52:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   for(int i=0; i<et.size(); i++) {
      |                ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 2 ms 1168 KB Output is correct
3 Correct 2 ms 1304 KB Output is correct
4 Correct 2 ms 1156 KB Output is correct
5 Correct 1 ms 1156 KB Output is correct
6 Correct 1 ms 1156 KB Output is correct
7 Correct 1 ms 1296 KB Output is correct
8 Correct 2 ms 1288 KB Output is correct
9 Correct 2 ms 1292 KB Output is correct
10 Correct 1 ms 1168 KB Output is correct
11 Correct 6 ms 1484 KB Output is correct
12 Correct 2 ms 1156 KB Output is correct
13 Correct 2 ms 1344 KB Output is correct
14 Correct 2 ms 1288 KB Output is correct
15 Correct 2 ms 1292 KB Output is correct
16 Correct 2 ms 1288 KB Output is correct
17 Correct 2 ms 1296 KB Output is correct
18 Correct 2 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 4712 KB Output is correct
2 Correct 23 ms 4632 KB Output is correct
3 Correct 26 ms 4788 KB Output is correct
4 Correct 13 ms 3108 KB Output is correct
5 Correct 14 ms 3748 KB Output is correct
6 Correct 14 ms 3504 KB Output is correct
7 Correct 13 ms 3528 KB Output is correct
8 Correct 13 ms 3576 KB Output is correct
9 Correct 13 ms 3492 KB Output is correct
10 Correct 11 ms 3112 KB Output is correct
11 Correct 12 ms 3120 KB Output is correct
12 Correct 14 ms 2960 KB Output is correct
13 Correct 11 ms 3052 KB Output is correct
14 Correct 12 ms 3232 KB Output is correct
15 Correct 12 ms 3088 KB Output is correct
16 Correct 13 ms 3104 KB Output is correct
17 Correct 13 ms 3068 KB Output is correct
18 Correct 13 ms 3132 KB Output is correct
19 Correct 13 ms 3108 KB Output is correct
20 Correct 11 ms 3744 KB Output is correct
21 Correct 10 ms 3748 KB Output is correct
22 Correct 13 ms 3372 KB Output is correct
23 Correct 13 ms 3504 KB Output is correct
24 Correct 13 ms 3524 KB Output is correct
25 Correct 13 ms 3504 KB Output is correct
26 Correct 13 ms 3504 KB Output is correct
27 Correct 13 ms 3512 KB Output is correct
28 Correct 13 ms 3496 KB Output is correct
29 Correct 12 ms 3404 KB Output is correct
30 Correct 12 ms 3508 KB Output is correct
31 Correct 1 ms 1164 KB Output is correct
32 Correct 2 ms 1164 KB Output is correct
33 Correct 2 ms 1296 KB Output is correct
34 Correct 2 ms 1164 KB Output is correct
35 Correct 1 ms 1164 KB Output is correct
36 Correct 2 ms 1164 KB Output is correct
37 Correct 2 ms 1164 KB Output is correct
38 Correct 1 ms 1164 KB Output is correct
39 Correct 1 ms 1156 KB Output is correct
40 Correct 1 ms 1168 KB Output is correct
41 Correct 1 ms 1184 KB Output is correct
42 Correct 2 ms 1164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1136 KB Output is correct
2 Correct 1 ms 1160 KB Output is correct
3 Correct 1 ms 1164 KB Output is correct
4 Correct 2 ms 1580 KB Output is correct
5 Correct 3 ms 1592 KB Output is correct
6 Correct 3 ms 1588 KB Output is correct
7 Correct 2 ms 1580 KB Output is correct
8 Correct 2 ms 1584 KB Output is correct
9 Correct 10 ms 4392 KB Output is correct
10 Correct 10 ms 4260 KB Output is correct
11 Correct 10 ms 4088 KB Output is correct
12 Correct 2 ms 1164 KB Output is correct
13 Correct 1 ms 1168 KB Output is correct
14 Correct 1 ms 1164 KB Output is correct
15 Correct 1 ms 1164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 4772 KB Output is correct
2 Correct 22 ms 4700 KB Output is correct
3 Correct 22 ms 4796 KB Output is correct
4 Correct 14 ms 3100 KB Output is correct
5 Correct 13 ms 3940 KB Output is correct
6 Correct 13 ms 3520 KB Output is correct
7 Correct 13 ms 3548 KB Output is correct
8 Correct 13 ms 3364 KB Output is correct
9 Correct 13 ms 3276 KB Output is correct
10 Correct 12 ms 3124 KB Output is correct
11 Correct 13 ms 3160 KB Output is correct
12 Correct 12 ms 2916 KB Output is correct
13 Correct 11 ms 2956 KB Output is correct
14 Correct 12 ms 3104 KB Output is correct
15 Correct 13 ms 3112 KB Output is correct
16 Correct 13 ms 3120 KB Output is correct
17 Correct 13 ms 3116 KB Output is correct
18 Correct 13 ms 3152 KB Output is correct
19 Correct 13 ms 3060 KB Output is correct
20 Correct 12 ms 3748 KB Output is correct
21 Correct 11 ms 3768 KB Output is correct
22 Correct 13 ms 3500 KB Output is correct
23 Correct 13 ms 3432 KB Output is correct
24 Correct 13 ms 3496 KB Output is correct
25 Correct 12 ms 3500 KB Output is correct
26 Correct 13 ms 3500 KB Output is correct
27 Correct 13 ms 3724 KB Output is correct
28 Correct 13 ms 3328 KB Output is correct
29 Correct 11 ms 3340 KB Output is correct
30 Correct 13 ms 3488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 4724 KB Output is correct
2 Correct 22 ms 4868 KB Output is correct
3 Correct 22 ms 4748 KB Output is correct
4 Correct 15 ms 3136 KB Output is correct
5 Correct 13 ms 4132 KB Output is correct
6 Correct 14 ms 3500 KB Output is correct
7 Correct 13 ms 3364 KB Output is correct
8 Correct 13 ms 3508 KB Output is correct
9 Correct 13 ms 3496 KB Output is correct
10 Correct 13 ms 3124 KB Output is correct
11 Correct 12 ms 3120 KB Output is correct
12 Correct 13 ms 2960 KB Output is correct
13 Correct 13 ms 2956 KB Output is correct
14 Correct 12 ms 3104 KB Output is correct
15 Correct 13 ms 3056 KB Output is correct
16 Correct 14 ms 3092 KB Output is correct
17 Correct 13 ms 3108 KB Output is correct
18 Correct 15 ms 3132 KB Output is correct
19 Correct 13 ms 3120 KB Output is correct
20 Correct 11 ms 3744 KB Output is correct
21 Correct 11 ms 3760 KB Output is correct
22 Correct 13 ms 3496 KB Output is correct
23 Correct 13 ms 3500 KB Output is correct
24 Correct 13 ms 3492 KB Output is correct
25 Correct 13 ms 3464 KB Output is correct
26 Correct 13 ms 3456 KB Output is correct
27 Correct 13 ms 3752 KB Output is correct
28 Correct 12 ms 3752 KB Output is correct
29 Correct 13 ms 3468 KB Output is correct
30 Correct 12 ms 3492 KB Output is correct
31 Correct 2 ms 1164 KB Output is correct
32 Correct 2 ms 1284 KB Output is correct
33 Correct 2 ms 1296 KB Output is correct
34 Correct 1 ms 1156 KB Output is correct
35 Correct 2 ms 1160 KB Output is correct
36 Correct 1 ms 1164 KB Output is correct
37 Correct 1 ms 1164 KB Output is correct
38 Incorrect 2 ms 1156 KB Output isn't correct
39 Halted 0 ms 0 KB -