Submission #812527

# Submission time Handle Problem Language Result Execution time Memory
812527 2023-08-07T09:06:31 Z BT21tata Digital Circuit (IOI22_circuit) C++17
Compilation error
0 ms 0 KB
#include "circuit.h"
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const ll MOD=1e9+2022;
const int N=2e5+5;
 
struct tree
{
    ll one, zero, lazy;
}t[4*N];
 
int nw[N], cnt, old[N], n, m;
ll suff[N], prv=1, a[N];
vector<int>g[N];
 
void dfs(int v)
{
    if(v<n)
    {
        old[cnt]=v;
        nw[v]=cnt++;
    }
    for(int u : g[v])
        dfs(u);
}
 
void calc(int v)
{
    if(v>=n)
    {
        a[v-n]=(1ll*prv*suff[cnt])%MOD;
        return;
    }
    else cnt++;
    
    for(int u : g[v])
        calc(u, v);
    
    if(v<n) prv=(1ll*prv*g[v].size())%MOD;
}
 
void build(int v, int l, int r, vector<int>&state)
{
    if(l==r)
    {
        if(state[l]) t[v]={a[l], 0, 0};
        else t[v]={0, a[l], 0};
        return;
    }
    
    int mid=(l+r)>>1;
    build(v<<1, l, mid, state);
    build(v<<1|1, mid+1, r, state);
 
    t[v]={(t[v<<1].one+t[v<<1|1].one)%MOD, (t[v<<1].zero+t[v<<1|1].zero)%MOD, 0};
}
 
void push(int v, int l, int r)
{
    swap(t[v].zero, t[v].one);
    t[v].lazy=0;
    if(l!=r)
    {
        t[v<<1].lazy^=1;
        t[v<<1|1].lazy^=1;
    }
}
 
void update(int v, int l, int r, int tl, int tr)
{
    if(t[v].lazy) push(v, l, r);
    if(r<tl or tr<l) return;
    if(tl<=l and r<=tr)
    {
        push(v, l, r);
        return;
    }
 
    int mid=(l+r)>>1;
    update(v<<1, l, mid, tl, tr);
    update(v<<1|1, mid+1, r, tl, tr);
 
    t[v]={(t[v<<1].one+t[v<<1|1].one)%MOD, (t[v<<1].zero+t[v<<1|1].zero)%MOD, 0};
}
 
void init(int N, int M, vector<int> p, vector<int> state)
{
    n=N; m=M;
    for(int i=1; i<n+m; i++)
        g[p[i]].push_back(i);
 
    dfs(0);
 
    suff[n]=1;
    for(int i=n-1; i>=0; i--)
    {
        suff[i]=1ll*suff[i+1]*g[old[i]].size();
        suff[i]%=MOD;
    }
    
    cnt=0;
    calc(0, -1);
 
    build(1, 0, m-1, state);
}
 
int count_ways(int l, int r)
{
    update(1, 0, m-1, l-n, r-n);
    return t[1].one;
}

Compilation message

circuit.cpp: In function 'void calc(int)':
circuit.cpp:38:18: error: too many arguments to function 'void calc(int)'
   38 |         calc(u, v);
      |                  ^
circuit.cpp:28:6: note: declared here
   28 | void calc(int v)
      |      ^~~~
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:103:15: error: too many arguments to function 'void calc(int)'
  103 |     calc(0, -1);
      |               ^
circuit.cpp:28:6: note: declared here
   28 | void calc(int v)
      |      ^~~~