Submission #101614

# Submission time Handle Problem Language Result Execution time Memory
101614 2019-03-19T05:17:30 Z Utaha Mechanical Doll (IOI18_doll) C++14
100 / 100
140 ms 15728 KB
/*input

*/
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
  out<<'('<<P.F<<','<<P.S<<')';
  return out;
}

//}}}
const ll maxn=1000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
int lg=1;
int revbit(int n){
  int ret=0;
  REP(i,lg) if(n&(1<<i)){
    ret^=(1<<(lg-1-i));
  }
  return ret;
}
int rev[maxn];
bool cmp(int i,int j){
  return rev[i]<rev[j];
}
vector<int> C,X,Y;
int pt=1;
int L[maxn],R[maxn];
vector<int> order;
vector<int> r;
int idx[maxn];
void create_circuit(int m,vector<int> a){
  if(SZ(a)==1){
    C.resize(m+1);
    REP(i,SZ(C)) C[i]=0;
    C[0]=a[0];
    C[a[0]]=0;
    answer(C,X,Y);
    return; 
  }
  a.pb(0);
  int n=SZ(a);
  REP(i,m+1) C.pb(-1);
  int N=2;
  while(N<n){
    N<<=1;
    ++lg;
  }
  REP(i,n) order.pb(N-i-1);
  REP(i,N) rev[i]=revbit(i);
  sort(ALL(order),cmp);
  r.resize(N);
  // for(int i:order) cout<<i<<' ';
  // cout<<endl;
  REP(i,SZ(order)){
    // cout<<"QAQ"<<order[i]<<' '<<i<<'\n';
    r[order[i]]=i;
  }
  // REP(i,SZ(C)) cout<<C[i]<<" \n"[i==SZ(C)-1];
  // cout<<"N:"<<N<<'\n';
  L[1]=0;R[1]=N;

  for(int i=1;i<N/2;i++){
    int mid=(L[i]+R[i])/2;
    L[i<<1]=L[i];R[i<<1]=mid;
    L[(i<<1)|1]=mid;R[(i<<1)|1]=R[i];
  }
  int pt=0;
  for(int i=1;i<N;i++){
    if(R[i]<=N-n) continue;
    idx[i]=pt++;
  }
  X.resize(pt);
  Y.resize(pt);
  // cout<<r[N-1]<<' '<<a[n-1]<<'\n';
  for(int i=1;i<N;i++){
    if(R[i]<=N-n) continue;
    if(L[i]==R[i]-2){
      if(L[i]>=N-n) X[idx[i]]=a[r[L[i]]];
      else X[idx[i]]=-1;

      if(L[i]+1>=N-n) Y[idx[i]]=a[r[L[i]+1]];
      else Y[idx[i]]=-1;
      continue;
    }
    int mid=(L[i]+R[i])/2;
    if(mid<=N-n) X[idx[i]]=-1;
    else X[idx[i]]=-1-idx[i<<1];
    if(R[i]<=N-n) Y[idx[i]]=-1;
    else Y[idx[i]]=-1-idx[(i<<1)|1];
  }
  // cout<<SZ(X)<<'\n';
  // REP(i,SZ(X)) cout<<-1-i<<' '<<X[i]<<' '<<Y[i]<<'\n';
  answer(C,X,Y);
}

// vector<int> meow;
// int main()
// {
//  int n,m;
//  cin>>m>>n;
//  meow.resize(n);
//  REP(i,n) cin>>meow[i];
//  create_circuit(m,meow);
//  return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 56 ms 6644 KB Output is correct
3 Correct 49 ms 6468 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 16 ms 1604 KB Output is correct
6 Correct 71 ms 8604 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 56 ms 6644 KB Output is correct
3 Correct 49 ms 6468 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 16 ms 1604 KB Output is correct
6 Correct 71 ms 8604 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 93 ms 12100 KB Output is correct
9 Correct 95 ms 12368 KB Output is correct
10 Correct 136 ms 15728 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 56 ms 6644 KB Output is correct
3 Correct 49 ms 6468 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 16 ms 1604 KB Output is correct
6 Correct 71 ms 8604 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 93 ms 12100 KB Output is correct
9 Correct 95 ms 12368 KB Output is correct
10 Correct 136 ms 15728 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 132 ms 15408 KB Output is correct
15 Correct 91 ms 11344 KB Output is correct
16 Correct 140 ms 14904 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 138 ms 15472 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 126 ms 10176 KB Output is correct
3 Correct 84 ms 10176 KB Output is correct
4 Correct 122 ms 13360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 126 ms 10176 KB Output is correct
3 Correct 84 ms 10176 KB Output is correct
4 Correct 122 ms 13360 KB Output is correct
5 Correct 129 ms 14768 KB Output is correct
6 Correct 133 ms 14444 KB Output is correct
7 Correct 132 ms 14548 KB Output is correct
8 Correct 130 ms 14156 KB Output is correct
9 Correct 87 ms 10256 KB Output is correct
10 Correct 126 ms 14104 KB Output is correct
11 Correct 123 ms 13740 KB Output is correct
12 Correct 84 ms 10432 KB Output is correct
13 Correct 90 ms 10900 KB Output is correct
14 Correct 88 ms 11084 KB Output is correct
15 Correct 94 ms 11148 KB Output is correct
16 Correct 3 ms 588 KB Output is correct
17 Correct 99 ms 8888 KB Output is correct
18 Correct 98 ms 10496 KB Output is correct
19 Correct 96 ms 10412 KB Output is correct
20 Correct 137 ms 13976 KB Output is correct
21 Correct 130 ms 13732 KB Output is correct
22 Correct 137 ms 13804 KB Output is correct