Submission #638459

# Submission time Handle Problem Language Result Execution time Memory
638459 2022-09-06T07:37:33 Z aris12345678 Digital Circuit (IOI22_circuit) C++17
0 / 100
370 ms 1852 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;

const int mxN = 100005;
const int mod = 1000002022;
int N, M, last;
vector<int> P, A;
int st[4*mxN];

int comb(int l, int r, int level) {
    if(level == last)
        return (l+r)%mod;
    if(l == 0)
        return r%mod;
    if(r == 0)
        return l%mod;
    return (l*r)%mod;
}

void build(int p, int l, int r, int level = 1) {
    if(l == r) {
        st[p] = A[l];
        return;
    } else {
        int md = (l+r)/2;
        build(2*p, l, md, level+1);
        build(2*p+1, md+1, r, level+1);
        st[p] = comb(st[2*p], st[2*p+1], level);
    }
}

void update(int p, int l, int r, int i, int level = 1) {
    if(l == r) {
        if(A[l] == 0)
            A[l] = 1;
        else
            A[l] = 0;
        st[p] = A[l];
        return;
    } else {
        int md = (l+r)/2;
        if(i <= md)
            update(2*p, l, md, i, level+1);
        else
            update(2*p+1, md+1, r, i, level+1);
        st[p] = comb(st[2*p], st[2*p+1], level);
    }
}

void init(int n, int m, vector<int> p, vector<int> a) {
    N = n, M = m;
    int last = log2(M);
    A.push_back(0);
    for(int i = 0; i < N+M; i++)
        P.push_back(p[i]);
    for(int i = 0; i < M; i++)
        A.push_back(a[i]);
    build(1, 1, M);
}

int count_ways(int l, int r) {
    update(1, 1, M, l);
    return st[1];
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:53:9: warning: unused variable 'last' [-Wunused-variable]
   53 |     int last = log2(M);
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 370 ms 1852 KB 1st lines differ - on the 1st token, expected: '431985922', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 370 ms 1852 KB 1st lines differ - on the 1st token, expected: '431985922', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -