Submission #152915

# Submission time Handle Problem Language Result Execution time Memory
152915 2019-09-10T12:56:11 Z Segtree Mechanical Doll (IOI18_doll) C++14
53 / 100
188 ms 17020 KB
#include "doll.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
ll tap(ll x){
    ll t=2;
    while(t<x)t*=2;
    return t;
}
vector<int> c,x,y;
void func(ll cur,vector<int> to){
    if(to.size()==1){
	c[cur]=to[0];
	return;
    }
    ll n=tap(to.size()); //cout<<"---"<<n<<endl;
    //n=2;
    int base=x.size();
    c[cur]=-base-1;
    for(int i=0;i<n-1;i++){
	x.push_back(-base-1);
	y.push_back(-base-1);
    }
    for(int i=1;i<n/2;i++){
	x[base+i-1]=-base-(i*2);
	y[base+i-1]=-base-(i*2+1);
    }
    ll p=0;
    for(int i=0;i<to.size()-1;i++){
	vector<bool> v;
	ll cop=i;
	for(int j=0;j<log2(n);j++){
	    v.push_back(cop&1);
	    cop>>=1;
	}
	reverse(v.begin(),v.end());
	ll ra=1,res=n;
	for(int j=0;j<v.size();j++){
	    res+=v[j]*ra;
	    ra*=2;
	}
	if(res%2==0)x[base+res/2-1]=to[p];
	if(res%2==1)y[base+res/2-1]=to[p];
	p++;
    }
    y[base+n-2]=to[p];
}

vector<int> too[100010];
void create_circuit(int M,vector<int> A){
    ll bef=0;
    for(int i=0;i<A.size();i++){
	too[bef].push_back(A[i]);
	bef=A[i];
    }
    too[bef].push_back(0);
    for(int i=0;i<=M;i++){
	c.push_back(0);
	if(too[i].size()>0){
	    func(i,too[i]);
	}
    }
    /*
    cout<<"C:";
    for(int i=0;i<c.size();i++)cout<<c[i]<<" "; cout<<endl;
    cout<<"X:"<<endl;
    for(int i=0;i<x.size();i++)cout<<x[i]<<" "<<y[i]<<endl;*/
    answer(c,x,y);
}
/*
int main(){
  vector<int> A(4);
  for(int i=0;i<4;i++)cin>>A[i];
  
  create_circuit(4,A);
  return 0;
}*/

Compilation message

doll.cpp: In function 'void func(ll, std::vector<int>)':
doll.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<to.size()-1;i++){
      |                 ~^~~~~~~~~~~~
doll.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int j=0;j<v.size();j++){
      |              ~^~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.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<A.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 44 ms 6500 KB Output is correct
3 Correct 27 ms 6108 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 14 ms 3908 KB Output is correct
6 Correct 46 ms 7820 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 44 ms 6500 KB Output is correct
3 Correct 27 ms 6108 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 14 ms 3908 KB Output is correct
6 Correct 46 ms 7820 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
8 Correct 81 ms 8716 KB Output is correct
9 Correct 71 ms 8752 KB Output is correct
10 Correct 111 ms 11056 KB Output is correct
11 Correct 3 ms 2552 KB Output is correct
12 Correct 4 ms 2632 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 44 ms 6500 KB Output is correct
3 Correct 27 ms 6108 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 14 ms 3908 KB Output is correct
6 Correct 46 ms 7820 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
8 Correct 81 ms 8716 KB Output is correct
9 Correct 71 ms 8752 KB Output is correct
10 Correct 111 ms 11056 KB Output is correct
11 Correct 3 ms 2552 KB Output is correct
12 Correct 4 ms 2632 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 127 ms 12820 KB Output is correct
15 Correct 70 ms 7652 KB Output is correct
16 Correct 108 ms 10204 KB Output is correct
17 Correct 3 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 4 ms 2636 KB Output is correct
20 Correct 123 ms 11692 KB Output is correct
21 Correct 3 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 2636 KB Output is partially correct
2 Correct 124 ms 7864 KB Output is correct
3 Partially correct 135 ms 10988 KB Output is partially correct
4 Partially correct 182 ms 11256 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 2636 KB Output is partially correct
2 Correct 124 ms 7864 KB Output is correct
3 Partially correct 135 ms 10988 KB Output is partially correct
4 Partially correct 182 ms 11256 KB Output is partially correct
5 Partially correct 147 ms 14716 KB Output is partially correct
6 Partially correct 163 ms 15744 KB Output is partially correct
7 Partially correct 139 ms 15548 KB Output is partially correct
8 Partially correct 154 ms 16520 KB Output is partially correct
9 Partially correct 144 ms 11852 KB Output is partially correct
10 Partially correct 188 ms 16836 KB Output is partially correct
11 Partially correct 170 ms 17020 KB Output is partially correct
12 Partially correct 122 ms 12084 KB Output is partially correct
13 Partially correct 95 ms 11280 KB Output is partially correct
14 Partially correct 96 ms 11000 KB Output is partially correct
15 Partially correct 89 ms 10548 KB Output is partially correct
16 Partially correct 5 ms 2892 KB Output is partially correct
17 Partially correct 104 ms 9828 KB Output is partially correct
18 Partially correct 123 ms 9796 KB Output is partially correct
19 Partially correct 105 ms 10392 KB Output is partially correct
20 Partially correct 132 ms 12572 KB Output is partially correct
21 Partially correct 162 ms 14944 KB Output is partially correct
22 Partially correct 133 ms 11916 KB Output is partially correct