Submission #1003649

# Submission time Handle Problem Language Result Execution time Memory
1003649 2024-06-20T14:38:37 Z AdamGS Amusement Park (JOI17_amusement_park) C++17
0 / 100
13 ms 3368 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e4+7;
vector<int>V[LIM];
ll F[LIM], odl[LIM], jaki[LIM], pre[LIM], n, X, akt;
int fnd(int x) {
  if(F[x]==x) return x;
  return F[x]=fnd(F[x]);
}
bool uni(int a, int b) {
  if(fnd(a)==fnd(b)) return false;
  F[fnd(b)]=fnd(a);
  return true;
}
void DFS(int x, int o) {
  pre[x]=akt++;
  for(auto i : V[x]) if(i!=o) {
    odl[i]=odl[x]+1;
    DFS(i, x);
  }
}
void Joi(int _n, int _m, int _A[], int _B[], ll _X, int _T) {
  n=_n; X=_X;
  rep(i, n) F[i];
  rep(i, _m) if(uni(_A[i], _B[i])) {
    V[_A[i]].pb(_B[i]);
    V[_B[i]].pb(_A[i]);
  }
  DFS(0, 0);
  bool gleb=false;
  rep(i, n) if(odl[i]>=59) gleb=true;
  if(gleb) {
    rep(i, n) if(X&(1ll<<(ll)(odl[i]%60))) jaki[i]=1;
  } else {
    rep(i, n) if(X&(1ll<<(ll)(pre[i]%60))) jaki[i]=1;
  }
  rep(i, n) MessageBoard(i, jaki[i]);
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e4+7;
vector<int>V[LIM];
bool kon=false;
ll F[LIM], odl[LIM], jaki[LIM], pre[LIM], oc[LIM], n, X, akt, wierz, licz;
int fnd(int x) {
  if(F[x]==x) return x;
  return F[x]=fnd(F[x]);
}
bool uni(int a, int b) {
  if(fnd(a)==fnd(b)) return false;
  F[fnd(b)]=fnd(a);
  return true;
}
void DFS(int x, int o) {
  pre[x]=akt++;
  for(auto i : V[x]) if(i!=o) {
    odl[i]=odl[x]+1;
    oc[i]=x;
    DFS(i, x);
  }
}
void DFS2(int x, int o) {
  if(licz) X|=1ll<<(ll)(pre[x]%60);
  if(pre[x]==59) kon=true;
  for(auto i : V[x]) {
    licz=Move(i);
    wierz=i;
    DFS2(i, x);
    if(kon) return;
    licz=Move(x);
    wierz=x;
  }
}
ll Ioi(int _n, int _m, int _A[], int _B[], int _P, int _V, int _T) {
  n=_n; wierz=_P; licz=_V;
  rep(i, n) F[i];
  rep(i, _m) if(uni(_A[i], _B[i])) {
    V[_A[i]].pb(_B[i]);
    V[_B[i]].pb(_A[i]);
  }
  DFS(0, 0);
  if(odl[wierz]>=59) {
    if(licz) X|=1ll<<(ll)(odl[wierz]%60);
    rep(i, 59) {
      licz=Move(oc[wierz]);
      wierz=oc[wierz];
      if(licz) X|=1ll<<(ll)(odl[wierz]%60);
    }
    return X;
  }
  while(wierz) {
    licz=Move(oc[wierz]);
    wierz=oc[wierz];
  }
  rep(i, n) if(odl[i]==59) {
    vector<ll>A;
    int x=i;
    while(x) {
      A.pb(x);
      x=oc[x];
    }
    reverse(all(A));
    if(licz) X|=1ll<<(ll)(odl[wierz]%60);
    for(auto j : A) {
      licz=Move(j);
      wierz=j;
      if(licz) X|=1ll<<(ll)(odl[wierz]%60);
    }
    return X;
  }
  DFS2(0, 0);
  return X;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, ll, int)':
Joi.cpp:31:16: warning: statement has no effect [-Wunused-value]
   31 |   rep(i, n) F[i];
      |             ~~~^

Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:45:16: warning: statement has no effect [-Wunused-value]
   45 |   rep(i, n) F[i];
      |             ~~~^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1296 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 3368 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1376 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 3100 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 3364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -