Submission #999501

# Submission time Handle Problem Language Result Execution time Memory
999501 2024-06-15T16:05:05 Z MarwenElarbi Mechanical Doll (IOI18_doll) C++17
100 / 100
106 ms 12424 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=2e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);
int n;
int cnt=0;
vector<int> tab(1<<18),x(1<<18),y(1<<18);
int build(int l,int r){
  if(l>=n){
    return -1;
  }else if(r-l<2){
    return 1;
  }else{
    int mid=(r+l)/2;
    int u=cnt++;
    y[u]=build(l,mid);
    x[u]=build(mid,r);
    return -u-1;
  }
}
void create_circuit(int M, std::vector<int> A){
  vector<int> C(M+1,-1);
  A.pb(0);
  n=A.size();
  int k=n;
  while(__builtin_popcount(k)!=1) k++;
  build(0,k);
  for(auto i:A){
    int cur=0;
    while(cur>=0){
      tab[cur]^=1;
      int w=-1-(tab[cur] ? x[cur] : y[cur]);
      if(w<0){
        (tab[cur] ? x[cur] : y[cur])=i;
        cur=-1;
      }else cur=w;
    }
  }
  x.resize(cnt);
  y.resize(cnt);
  answer (C,x,y);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 31 ms 6712 KB Output is correct
3 Correct 32 ms 6728 KB Output is correct
4 Correct 2 ms 3416 KB Output is correct
5 Correct 7 ms 4564 KB Output is correct
6 Correct 43 ms 8452 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 31 ms 6712 KB Output is correct
3 Correct 32 ms 6728 KB Output is correct
4 Correct 2 ms 3416 KB Output is correct
5 Correct 7 ms 4564 KB Output is correct
6 Correct 43 ms 8452 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 57 ms 9212 KB Output is correct
9 Correct 58 ms 9664 KB Output is correct
10 Correct 95 ms 12424 KB Output is correct
11 Correct 2 ms 3672 KB Output is correct
12 Correct 2 ms 3420 KB Output is correct
13 Correct 2 ms 3368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 31 ms 6712 KB Output is correct
3 Correct 32 ms 6728 KB Output is correct
4 Correct 2 ms 3416 KB Output is correct
5 Correct 7 ms 4564 KB Output is correct
6 Correct 43 ms 8452 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 57 ms 9212 KB Output is correct
9 Correct 58 ms 9664 KB Output is correct
10 Correct 95 ms 12424 KB Output is correct
11 Correct 2 ms 3672 KB Output is correct
12 Correct 2 ms 3420 KB Output is correct
13 Correct 2 ms 3368 KB Output is correct
14 Correct 78 ms 12176 KB Output is correct
15 Correct 59 ms 8900 KB Output is correct
16 Correct 85 ms 11920 KB Output is correct
17 Correct 2 ms 3420 KB Output is correct
18 Correct 2 ms 3416 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 106 ms 12376 KB Output is correct
21 Correct 2 ms 3416 KB Output is correct
22 Correct 1 ms 3396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 2 ms 3452 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 3 ms 3536 KB Output is correct
6 Correct 2 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 52 ms 8048 KB Output is correct
3 Correct 55 ms 8008 KB Output is correct
4 Correct 81 ms 10668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 52 ms 8048 KB Output is correct
3 Correct 55 ms 8008 KB Output is correct
4 Correct 81 ms 10668 KB Output is correct
5 Correct 85 ms 11920 KB Output is correct
6 Correct 79 ms 11824 KB Output is correct
7 Correct 87 ms 11828 KB Output is correct
8 Correct 81 ms 11460 KB Output is correct
9 Correct 53 ms 8012 KB Output is correct
10 Correct 77 ms 11312 KB Output is correct
11 Correct 86 ms 11056 KB Output is correct
12 Correct 53 ms 8264 KB Output is correct
13 Correct 59 ms 8776 KB Output is correct
14 Correct 57 ms 8776 KB Output is correct
15 Correct 58 ms 9036 KB Output is correct
16 Correct 3 ms 3676 KB Output is correct
17 Correct 48 ms 8256 KB Output is correct
18 Correct 55 ms 8268 KB Output is correct
19 Correct 60 ms 8268 KB Output is correct
20 Correct 84 ms 11316 KB Output is correct
21 Correct 89 ms 11060 KB Output is correct
22 Correct 78 ms 11060 KB Output is correct