Submission #470498

# Submission time Handle Problem Language Result Execution time Memory
470498 2021-09-04T05:53:49 Z Cross_Ratio Mechanical Doll (IOI18_doll) C++14
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

void create_circuit(int M, vector<int> A) {
    int sz;
    int i;
    int N = A.size();
    for(sz=1;sz<2*N;sz*=2) {}
    vector<int> C, X, Y;
    C.resize(M+1);
    fill(C.begin(),C.end(),-1);
    X.resize(sz);
    Y.resize(sz);
    for(i=1;i<sz/2;i++) {
        X[i] = -2*i;
        Y[i] = -2*i-1;
    }
    vector<bool> isX(sz, true);
    for(i=0;i<sz/2;i++) {
        int pt = 1;
        while(pt<sz/2) {
            if(isX[pt]) {
                isX[pt] = false;
                pt = 2*pt;
            }
            else {
                isX[pt] = true;
                pt = 2*pt + 1;
            }
        }
        if(isX[pt]) {
            if(i==sz/2-1) X[pt] = 0;
            else if(i < N) X[pt] = A[i];
            else X[pt] = -1;
            isX[pt] = false;
        }
        else {
            if(i==sz/2-1) Y[pt] = 0;
            else if(i < N) Y[pt] = A[i];
            else Y[pt] = -1;
            isX[pt] = true;
        }
    }
    for(i=0;i<X.size()-1;i++) {
        X[i] = X[i+1];
        Y[i] = Y[i+1];
    }
    X.pop_back();
    Y.pop_back();
    answer(C, X, Y);
    for(i=0;i<X.size();i++) {
        //cout << -i-1 << " -> " << X[i] << ' ' << Y[i] << '\n';
    }
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:45:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(i=0;i<X.size()-1;i++) {
      |             ~^~~~~~~~~~~
doll.cpp:52:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(i=0;i<X.size();i++) {
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -