Submission #1110126

# Submission time Handle Problem Language Result Execution time Memory
1110126 2024-11-08T19:32:04 Z ASN49K Digital Circuit (IOI22_circuit) C++17
18 / 100
3000 ms 10064 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100'000,mod=1e9+2022;
int add(int x,int y)
{
    return (x+y)%mod;
}
void add_self(int& x,int y)
{
    x+=y;
    if(x>=mod)
    {
        x-=mod;
    }
    if(x<0)
    {
        x+=mod;
    }
}
int prod(int x,int y)
{
    return (1LL*x*y)%mod;
}
int n,m;
vector<int>g[2*N],a;
bool lazy[5*N];
int aint[5*N][2],dp[N],produs[N];


void push_down(int nod)
{
    if(lazy[nod])
    {
        swap(aint[2*nod+1][0] , aint[2*nod+1][1]);
        swap(aint[2*nod+2][0] , aint[2*nod+2][1]);
        lazy[2*nod+1]^=true;
        lazy[2*nod+2]^=true;
        lazy[nod]=false;
    }
}
void recalc(int nod)
{
    int l=2*nod+1,r=2*nod+2;
}
void update(int nod,int st,int dr,int l,int r)
{
    if(st>r || dr<l)
    {
        return;
    }
    if(l<=st && dr<=r)
    {
        lazy[nod]^=true;
        swap(aint[nod][0] , aint[nod][1]);
        return;
    }
    int m=(st+dr)/2;
    push_down(nod);
    update(2*nod+1,st,m,l,r);
    update(2*nod+2,m+1,dr,l,r);
    recalc(nod);
}

void dfs1(int nod)
{
    produs[nod]=max(1,(int)g[nod].size());
    for(auto &c:g[nod])
    {
        dfs1(c);
        produs[nod]=prod(produs[nod] , produs[c]);
    }
}
void dfs2(int nod)
{
    int sz=(int)g[nod].size();
    if(g[nod].empty())
    {
        return;
    }
    vector<int>suf(sz,1),pref(sz,1);
    for(int i=1;i<sz;i++)
    {
        suf[i]=prod(suf[i-1],produs[g[nod][i-1]]);
    }
    for(int i=sz-2;i>=0;i--)
    {
        pref[i]=prod(pref[i+1],produs[g[nod][i+1]]);
    }
    for(int i=0;i<sz;i++)
    {
        int c=g[nod][i];
        dp[c]=prod(dp[nod] , prod(suf[i] , pref[i]));
        dfs2(c);
    }
}

void init(int nn, int mm, std::vector<int> pp, std::vector<int> init_a)
{
    n=nn;
    m=mm;
    for(int i=1;i<n+m;i++)
    {
        g[pp[i]].push_back(i);
    }
    a=init_a;
    dp[0]=1;
    dfs1(0);
    dfs2(0);
}
int count_ways(int l, int r)
{
    l-=n;
    r-=n;
    for(int i=l;i<=r;i++)
    {
        a[i]^=1;
    }
    int rez=0;
    for(int i=0;i<m;i++)
    {
        if(a[i])
        {
            add_self(rez , dp[i+n]);
        }
    }
    return rez;
}

Compilation message

circuit.cpp: In function 'void recalc(int)':
circuit.cpp:45:9: warning: unused variable 'l' [-Wunused-variable]
   45 |     int l=2*nod+1,r=2*nod+2;
      |         ^
circuit.cpp:45:19: warning: unused variable 'r' [-Wunused-variable]
   45 |     int l=2*nod+1,r=2*nod+2;
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8016 KB Output is correct
4 Correct 3 ms 8032 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 2 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 2 ms 8016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8184 KB Output is correct
4 Correct 3 ms 8016 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 3 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 3 ms 8016 KB Output is correct
9 Correct 3 ms 8188 KB Output is correct
10 Correct 3 ms 8272 KB Output is correct
11 Correct 3 ms 8272 KB Output is correct
12 Correct 4 ms 8016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8016 KB Output is correct
4 Correct 3 ms 8032 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 2 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 2 ms 8016 KB Output is correct
9 Correct 3 ms 8016 KB Output is correct
10 Correct 3 ms 8016 KB Output is correct
11 Correct 3 ms 8184 KB Output is correct
12 Correct 3 ms 8016 KB Output is correct
13 Correct 3 ms 8016 KB Output is correct
14 Correct 3 ms 8016 KB Output is correct
15 Correct 3 ms 8016 KB Output is correct
16 Correct 3 ms 8016 KB Output is correct
17 Correct 3 ms 8188 KB Output is correct
18 Correct 3 ms 8272 KB Output is correct
19 Correct 3 ms 8272 KB Output is correct
20 Correct 4 ms 8016 KB Output is correct
21 Correct 3 ms 8016 KB Output is correct
22 Correct 3 ms 8016 KB Output is correct
23 Correct 3 ms 8192 KB Output is correct
24 Correct 3 ms 8016 KB Output is correct
25 Correct 3 ms 8016 KB Output is correct
26 Correct 3 ms 8016 KB Output is correct
27 Correct 4 ms 8016 KB Output is correct
28 Correct 3 ms 8016 KB Output is correct
29 Correct 3 ms 8016 KB Output is correct
30 Correct 3 ms 8016 KB Output is correct
31 Correct 3 ms 8272 KB Output is correct
32 Correct 4 ms 8016 KB Output is correct
33 Correct 3 ms 8112 KB Output is correct
34 Correct 4 ms 8016 KB Output is correct
35 Correct 3 ms 8016 KB Output is correct
36 Correct 4 ms 8272 KB Output is correct
37 Correct 3 ms 8272 KB Output is correct
38 Correct 3 ms 8272 KB Output is correct
39 Correct 3 ms 8016 KB Output is correct
40 Correct 3 ms 8016 KB Output is correct
41 Correct 3 ms 8016 KB Output is correct
42 Correct 3 ms 8016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 10064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 10064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8184 KB Output is correct
4 Correct 3 ms 8016 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 3 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 3 ms 8016 KB Output is correct
9 Correct 3 ms 8188 KB Output is correct
10 Correct 3 ms 8272 KB Output is correct
11 Correct 3 ms 8272 KB Output is correct
12 Correct 4 ms 8016 KB Output is correct
13 Execution timed out 3084 ms 10064 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8016 KB Output is correct
4 Correct 3 ms 8032 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 2 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 2 ms 8016 KB Output is correct
9 Correct 3 ms 8016 KB Output is correct
10 Correct 3 ms 8016 KB Output is correct
11 Correct 3 ms 8184 KB Output is correct
12 Correct 3 ms 8016 KB Output is correct
13 Correct 3 ms 8016 KB Output is correct
14 Correct 3 ms 8016 KB Output is correct
15 Correct 3 ms 8016 KB Output is correct
16 Correct 3 ms 8016 KB Output is correct
17 Correct 3 ms 8188 KB Output is correct
18 Correct 3 ms 8272 KB Output is correct
19 Correct 3 ms 8272 KB Output is correct
20 Correct 4 ms 8016 KB Output is correct
21 Correct 3 ms 8016 KB Output is correct
22 Correct 3 ms 8016 KB Output is correct
23 Correct 3 ms 8192 KB Output is correct
24 Correct 3 ms 8016 KB Output is correct
25 Correct 3 ms 8016 KB Output is correct
26 Correct 3 ms 8016 KB Output is correct
27 Correct 4 ms 8016 KB Output is correct
28 Correct 3 ms 8016 KB Output is correct
29 Correct 3 ms 8016 KB Output is correct
30 Correct 3 ms 8016 KB Output is correct
31 Correct 3 ms 8272 KB Output is correct
32 Correct 4 ms 8016 KB Output is correct
33 Correct 3 ms 8112 KB Output is correct
34 Correct 4 ms 8016 KB Output is correct
35 Correct 3 ms 8016 KB Output is correct
36 Correct 4 ms 8272 KB Output is correct
37 Correct 3 ms 8272 KB Output is correct
38 Correct 3 ms 8272 KB Output is correct
39 Correct 3 ms 8016 KB Output is correct
40 Correct 3 ms 8016 KB Output is correct
41 Correct 3 ms 8016 KB Output is correct
42 Correct 3 ms 8016 KB Output is correct
43 Correct 1978 ms 8272 KB Output is correct
44 Correct 2755 ms 8272 KB Output is correct
45 Correct 2879 ms 8272 KB Output is correct
46 Execution timed out 3032 ms 8408 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8016 KB Output is correct
2 Correct 3 ms 8016 KB Output is correct
3 Correct 3 ms 8016 KB Output is correct
4 Correct 3 ms 8032 KB Output is correct
5 Correct 3 ms 8016 KB Output is correct
6 Correct 2 ms 8016 KB Output is correct
7 Correct 3 ms 8016 KB Output is correct
8 Correct 2 ms 8016 KB Output is correct
9 Correct 3 ms 8016 KB Output is correct
10 Correct 3 ms 8016 KB Output is correct
11 Correct 3 ms 8184 KB Output is correct
12 Correct 3 ms 8016 KB Output is correct
13 Correct 3 ms 8016 KB Output is correct
14 Correct 3 ms 8016 KB Output is correct
15 Correct 3 ms 8016 KB Output is correct
16 Correct 3 ms 8016 KB Output is correct
17 Correct 3 ms 8188 KB Output is correct
18 Correct 3 ms 8272 KB Output is correct
19 Correct 3 ms 8272 KB Output is correct
20 Correct 4 ms 8016 KB Output is correct
21 Correct 3 ms 8016 KB Output is correct
22 Correct 3 ms 8016 KB Output is correct
23 Correct 3 ms 8192 KB Output is correct
24 Correct 3 ms 8016 KB Output is correct
25 Correct 3 ms 8016 KB Output is correct
26 Correct 3 ms 8016 KB Output is correct
27 Correct 4 ms 8016 KB Output is correct
28 Correct 3 ms 8016 KB Output is correct
29 Correct 3 ms 8016 KB Output is correct
30 Correct 3 ms 8016 KB Output is correct
31 Correct 3 ms 8272 KB Output is correct
32 Correct 4 ms 8016 KB Output is correct
33 Correct 3 ms 8112 KB Output is correct
34 Correct 4 ms 8016 KB Output is correct
35 Correct 3 ms 8016 KB Output is correct
36 Correct 4 ms 8272 KB Output is correct
37 Correct 3 ms 8272 KB Output is correct
38 Correct 3 ms 8272 KB Output is correct
39 Correct 3 ms 8016 KB Output is correct
40 Correct 3 ms 8016 KB Output is correct
41 Correct 3 ms 8016 KB Output is correct
42 Correct 3 ms 8016 KB Output is correct
43 Execution timed out 3084 ms 10064 KB Time limit exceeded
44 Halted 0 ms 0 KB -