Submission #796830

# Submission time Handle Problem Language Result Execution time Memory
796830 2023-07-28T19:29:41 Z anton Amusement Park (JOI17_amusement_park) C++17
10 / 100
19 ms 5484 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<<endl;
  order.push_back(u);
  vis[u] = true;

  for(auto v: adj[u]){
    if(!vis[v]){
      dfs(v, u);
    }
  }
  //cout<<u<<endl;
}
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], among_peers[MAX_N];
static bool vis2[MAX_N], found[K];
static int nb_vis =0;
static vector<int> order2;
static vector<int> adj2[MAX_N];
static vector<int> ch[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]){
      among_peers[v] = ch[u].size();
      ch[u].push_back(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;
  }
}

void explore_after(int u, int order){
  //cout<<"exploring "<<u<<" after "<<order<<endl;
  //cout<<mod[u]<<endl;
  for(int i = order; i<ch[u].size() && nb_found<K; i++){
    int next = ch[u][i];
    int val = Move(next);
    find(mod[next]%K, val);
    explore_after(next, 0);
    if(nb_found<K){
      Move(u);
    }
  }
  //cout<<"done "<<u<<endl;
}

void explore_before(int u, int order){
  //cout<<"exploring "<<u<<" before "<<order<<endl;
  //cout<<mod[u]<<endl;
  for(int i = order; i>=0 && nb_found<K; i--){
    int next = ch[u][i];
    int val = Move(next);
    find(mod[next]%K, val);
    explore_before(next, ch[next].size()-1);
    if(nb_found<K){
      Move(u);
    }
  }
}
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;

  explore_after(cur, 0);
  //explore_before(cur, ch[cur].size()-1);
  while(nb_found<K){
    ////cout<<anc[cur]<<endl;
    int val =Move(anc[cur]);
    
    find(mod[anc[cur]]%K, val);
    explore_after(anc[cur], among_peers[cur]+1);
    if(sz[anc[cur]]<K){
      explore_before(anc[cur], among_peers[cur]-1);
    }
    //explore_before(anc[cur], among_peers[cur]-1);
    cur = anc[cur];
  }

  /*////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 'void explore_after(int, int)':
Ioi.cpp:49:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int i = order; i<ch[u].size() && nb_found<K; i++){
      |                      ~^~~~~~~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:88:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |   for(int i= 0; i< order2.size(); i++){
      |                 ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1292 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 5460 KB Output is correct
2 Correct 18 ms 5416 KB Output is correct
3 Correct 18 ms 5388 KB Output is correct
4 Correct 11 ms 3492 KB Output is correct
5 Correct 11 ms 4396 KB Output is correct
6 Correct 11 ms 3924 KB Output is correct
7 Correct 11 ms 4132 KB Output is correct
8 Correct 12 ms 4204 KB Output is correct
9 Correct 12 ms 4072 KB Output is correct
10 Correct 9 ms 3500 KB Output is correct
11 Correct 10 ms 3468 KB Output is correct
12 Correct 9 ms 3312 KB Output is correct
13 Correct 9 ms 3340 KB Output is correct
14 Correct 12 ms 3408 KB Output is correct
15 Correct 11 ms 3492 KB Output is correct
16 Correct 10 ms 3492 KB Output is correct
17 Correct 10 ms 3472 KB Output is correct
18 Correct 10 ms 3468 KB Output is correct
19 Correct 11 ms 3504 KB Output is correct
20 Incorrect 9 ms 4344 KB Wrong Answer [6]
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1292 KB Output is correct
2 Correct 2 ms 1292 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1968 KB Output is correct
5 Correct 2 ms 1972 KB Output is correct
6 Correct 3 ms 1956 KB Output is correct
7 Correct 2 ms 1968 KB Output is correct
8 Correct 2 ms 1964 KB Output is correct
9 Correct 9 ms 5156 KB Output is correct
10 Correct 9 ms 5156 KB Output is correct
11 Correct 9 ms 5112 KB Output is correct
12 Correct 2 ms 1292 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1280 KB Output is correct
15 Correct 1 ms 1284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 5392 KB Output is correct
2 Partially correct 18 ms 5396 KB Partially correct
3 Partially correct 18 ms 5400 KB Partially correct
4 Correct 11 ms 3484 KB Output is correct
5 Correct 11 ms 4772 KB Output is correct
6 Correct 11 ms 4132 KB Output is correct
7 Correct 11 ms 4096 KB Output is correct
8 Correct 11 ms 3796 KB Output is correct
9 Correct 10 ms 3852 KB Output is correct
10 Correct 9 ms 3476 KB Output is correct
11 Correct 9 ms 3504 KB Output is correct
12 Correct 9 ms 3308 KB Output is correct
13 Correct 10 ms 3296 KB Output is correct
14 Correct 9 ms 3424 KB Output is correct
15 Correct 11 ms 3500 KB Output is correct
16 Correct 10 ms 3496 KB Output is correct
17 Correct 11 ms 3584 KB Output is correct
18 Correct 10 ms 3476 KB Output is correct
19 Correct 11 ms 3492 KB Output is correct
20 Incorrect 9 ms 4260 KB Wrong Answer [6]
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 5484 KB Output is correct
2 Correct 18 ms 5392 KB Output is correct
3 Incorrect 18 ms 5376 KB Output isn't correct
4 Halted 0 ms 0 KB -