Submission #796801

# Submission time Handle Problem Language Result Execution time Memory
796801 2023-07-28T18:32:11 Z anton Amusement Park (JOI17_amusement_park) C++17
80 / 100
18 ms 4980 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;

static const int MAX_N = 1e4;
static const int K = 60;
static int x[K];
static bool vis[MAX_N];
static vector<int> order;
static vector<int> adj[MAX_N];

void dfs(int u, int a){
  MessageBoard(u, x[order.size()%K]);
  //cout<<u<<" "<<order.size()%K<<endl;
  order.push_back(u);
  vis[u] = true;

  for(auto v: adj[u]){
    if(!vis[v]){
      dfs(v, u);
    }
  }
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
  for(long long i = 0; i<K; i++){
    if((X&(1LL<<i))>0LL){
      x[i] = 1;
    }
    else{
      x[i] = 0;
    }
    //cout<<x[i]<<" ";
  }

  for(int i = 0; i<M; i++){
    int a, b;
    a = A[i];
    b =B[i];
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  dfs(0, -1);
}
#include "Ioi.h"
#include<bits/stdc++.h>

using namespace std;

const int MAX_N = 1e4;
const int K = 60;
static int x2[K], mod[MAX_N], anc[MAX_N], sz[MAX_N], place[MAX_N];
static bool vis2[MAX_N], found[K];
static int nb_vis =0;
static vector<int> order2;
static vector<int> adj2[MAX_N];

void dfs2(int u, int a){
  vis2[u] = true;
  anc[u] =a;
  mod[u] = nb_vis;
  place[u] = order2.size();
  nb_vis++;
  //cout<<u<<" "<<mod[u]<<endl;
  order2.push_back(u);
  sz[u] =1;

  for(auto v: adj2[u]){
    if(!vis2[v]){
      dfs2(v, u);
      sz[u] += sz[v];
      order2.push_back(u);
    }
  }

}
int nb_found = 0;

void find(int id, int v){
  if(!found[id]){
    found[id] = true;
    nb_found++;
    x2[id] = v;
  }
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {

  for(int i = 0; i<M; i++){
    int a, b;
    a = A[i];
    b =B[i];
    adj2[a].push_back(b);
    adj2[b].push_back(a);
  }

  dfs2(0, -1);

  int cur = P;
  find(mod[cur]%K, V);
  for(int i= 0; i< order2.size(); i++){
    //cout<<i<<" "<<order2[i]<<" | ";
  }
  //cout<<endl;

  while(sz[cur]<K){
    //cout<<anc[cur]<<endl;
    int val =Move(anc[cur]);
    cur = anc[cur];
    find(mod[cur]%K, val);
  }

  //cout<<"done going up "<<cur<<" "<<endl;
  int pos = place[cur]+1;
  //cout<<"first at "<<pos<<endl;
  for(int i = pos; nb_found<K; i++){
    //cout<<"going to "<<order2[i]<<endl;
    int val =Move(order2[i]);
    cur= order2[i];
    find(mod[cur]%K, val); 
  }

  long long res= 0;
  for(long long i = 0; i<K; i++){
    if(x2[i]){
      res+=(1LL<<i);
    }
  }

  //cout<<res<<endl;
  return res;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for(int i= 0; i< order2.size(); i++){
      |                 ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1028 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1036 KB Output is correct
5 Correct 1 ms 1032 KB Output is correct
6 Correct 1 ms 1024 KB Output is correct
7 Correct 2 ms 1164 KB Output is correct
8 Correct 2 ms 1160 KB Output is correct
9 Correct 2 ms 1040 KB Output is correct
10 Correct 1 ms 1036 KB Output is correct
11 Correct 3 ms 1496 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 2 ms 1244 KB Output is correct
14 Correct 1 ms 1240 KB Output is correct
15 Correct 2 ms 1168 KB Output is correct
16 Correct 1 ms 1164 KB Output is correct
17 Correct 1 ms 1160 KB Output is correct
18 Correct 1 ms 1160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 4968 KB Output is correct
2 Correct 17 ms 4872 KB Output is correct
3 Correct 17 ms 4952 KB Output is correct
4 Correct 10 ms 3108 KB Output is correct
5 Correct 10 ms 3752 KB Output is correct
6 Correct 9 ms 3632 KB Output is correct
7 Correct 10 ms 3644 KB Output is correct
8 Correct 10 ms 3680 KB Output is correct
9 Correct 10 ms 3680 KB Output is correct
10 Correct 9 ms 3244 KB Output is correct
11 Correct 9 ms 3272 KB Output is correct
12 Correct 9 ms 3096 KB Output is correct
13 Correct 9 ms 3084 KB Output is correct
14 Correct 9 ms 3060 KB Output is correct
15 Correct 9 ms 3112 KB Output is correct
16 Correct 9 ms 3084 KB Output is correct
17 Correct 9 ms 3124 KB Output is correct
18 Correct 9 ms 3116 KB Output is correct
19 Correct 9 ms 3124 KB Output is correct
20 Correct 8 ms 3752 KB Output is correct
21 Correct 8 ms 3716 KB Output is correct
22 Correct 9 ms 3596 KB Output is correct
23 Correct 10 ms 3620 KB Output is correct
24 Correct 10 ms 3496 KB Output is correct
25 Correct 10 ms 3632 KB Output is correct
26 Correct 10 ms 3540 KB Output is correct
27 Correct 10 ms 3760 KB Output is correct
28 Correct 11 ms 3752 KB Output is correct
29 Correct 9 ms 3392 KB Output is correct
30 Correct 9 ms 3488 KB Output is correct
31 Correct 1 ms 1036 KB Output is correct
32 Correct 1 ms 1028 KB Output is correct
33 Correct 1 ms 1160 KB Output is correct
34 Correct 1 ms 1028 KB Output is correct
35 Correct 1 ms 1032 KB Output is correct
36 Correct 1 ms 1028 KB Output is correct
37 Correct 2 ms 1028 KB Output is correct
38 Correct 1 ms 1032 KB Output is correct
39 Correct 1 ms 1028 KB Output is correct
40 Correct 2 ms 1036 KB Output is correct
41 Correct 1 ms 1036 KB Output is correct
42 Correct 1 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1028 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 1 ms 1036 KB Output is correct
4 Correct 2 ms 1596 KB Output is correct
5 Correct 2 ms 1580 KB Output is correct
6 Correct 2 ms 1592 KB Output is correct
7 Correct 2 ms 1580 KB Output is correct
8 Correct 2 ms 1580 KB Output is correct
9 Correct 8 ms 4392 KB Output is correct
10 Correct 10 ms 4500 KB Output is correct
11 Correct 9 ms 4384 KB Output is correct
12 Correct 2 ms 1040 KB Output is correct
13 Correct 1 ms 1028 KB Output is correct
14 Correct 1 ms 1036 KB Output is correct
15 Correct 1 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 4924 KB Output is correct
2 Correct 17 ms 4884 KB Output is correct
3 Correct 17 ms 4864 KB Output is correct
4 Correct 9 ms 3208 KB Output is correct
5 Partially correct 10 ms 4016 KB Partially correct
6 Correct 12 ms 3752 KB Output is correct
7 Correct 10 ms 3624 KB Output is correct
8 Correct 10 ms 3368 KB Output is correct
9 Correct 10 ms 3492 KB Output is correct
10 Correct 9 ms 3204 KB Output is correct
11 Correct 9 ms 3192 KB Output is correct
12 Correct 9 ms 3084 KB Output is correct
13 Correct 9 ms 3064 KB Output is correct
14 Correct 9 ms 3068 KB Output is correct
15 Correct 9 ms 3112 KB Output is correct
16 Correct 9 ms 3128 KB Output is correct
17 Correct 10 ms 3116 KB Output is correct
18 Partially correct 11 ms 3480 KB Partially correct
19 Correct 10 ms 3112 KB Output is correct
20 Correct 8 ms 3752 KB Output is correct
21 Correct 8 ms 3756 KB Output is correct
22 Correct 10 ms 3636 KB Output is correct
23 Correct 10 ms 3560 KB Output is correct
24 Correct 9 ms 3496 KB Output is correct
25 Correct 10 ms 3712 KB Output is correct
26 Correct 10 ms 3624 KB Output is correct
27 Correct 11 ms 3748 KB Output is correct
28 Correct 9 ms 3504 KB Output is correct
29 Correct 9 ms 3464 KB Output is correct
30 Correct 11 ms 3484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 4980 KB Output is correct
2 Correct 16 ms 4888 KB Output is correct
3 Correct 17 ms 4944 KB Output is correct
4 Correct 10 ms 3208 KB Output is correct
5 Incorrect 10 ms 4156 KB Output isn't correct
6 Halted 0 ms 0 KB -