Submission #825667

# Submission time Handle Problem Language Result Execution time Memory
825667 2023-08-15T06:58:59 Z ttamx Digital Circuit (IOI22_circuit) C++17
52 / 100
881 ms 18056 KB
#include "circuit.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=1e5+5;
const int M=2e5+5;
const int K=1<<18;
const ll mod=1e9+2022;

int n,m;
int a[N];
ll pw[M];
ll mul[N];
vector<int> adj[N];

struct segtree{
	ll t[K],all[K];
	bool lz[K];
	void pushlz(int l,int r,int i){
		if(!lz[i])return;
		t[i]=(mod+all[i]-t[i])%mod;
		if(l<r){
			lz[i*2]^=true;
			lz[i*2+1]^=true;
		}
		lz[i]=false;
	}
	void build(int l,int r,int i){
		if(l==r){
			t[i]=a[l]*mul[l];
			all[i]=mul[l];
			return;
		}
		int m=(l+r)/2;
		build(l,m,i*2);
		build(m+1,r,i*2+1);
		t[i]=(t[i*2]+t[i*2+1])%mod;
		all[i]=(all[i*2]+all[i*2+1])%mod;
	}
	void build(){
		build(1,m,1);
	}
	void update(int l,int r,int i,int x,int y){
		pushlz(l,r,i);
		if(y<l||r<x)return;
		if(x<=l&&r<=y)return lz[i]=true,pushlz(l,r,i),void();
		int m=(l+r)/2;
		update(l,m,i*2,x,y);
		update(m+1,r,i*2+1,x,y);
		t[i]=(t[i*2]+t[i*2+1])%mod;
	}
	void update(int x,int y){
		update(1,m,1,x,y);
	}
}s;

void dfs(int u,int d=0){
	if(u>n)return void(mul[u-n]=pw[n-d]);
	for(auto v:adj[u])dfs(v,d+1);
}

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
	n=N,m=M;
	pw[0]=1;
	for(int i=1;i<=n+m;i++)pw[i]=pw[i-1]*2%mod;
	for(int i=1;i<=m;i++)a[i]=A[i-1];
	for(int i=1;i<n+m;i++){
		adj[P[i]+1].emplace_back(i+1);
	}
	dfs(1);
	s.build();
	int cur=1;
}

int count_ways(int L, int R) {
	L-=n-1;
	R-=n-1;
	s.update(L,R);
	return s.t[1];
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:75:6: warning: unused variable 'cur' [-Wunused-variable]
   75 |  int cur=1;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2768 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2768 KB Output is correct
7 Correct 2 ms 2808 KB Output is correct
8 Correct 2 ms 2768 KB Output is correct
9 Correct 2 ms 2768 KB Output is correct
10 Correct 2 ms 2768 KB Output is correct
11 Correct 2 ms 2768 KB Output is correct
12 Correct 2 ms 2724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2768 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 1 ms 2768 KB Output is correct
15 Correct 2 ms 2808 KB Output is correct
16 Correct 2 ms 2768 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2724 KB Output is correct
21 Incorrect 2 ms 2768 KB 1st lines differ - on the 1st token, expected: '759476520', found: '833967706'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 432 ms 6396 KB Output is correct
2 Correct 617 ms 10056 KB Output is correct
3 Correct 632 ms 10008 KB Output is correct
4 Correct 655 ms 10260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 432 ms 6396 KB Output is correct
2 Correct 617 ms 10056 KB Output is correct
3 Correct 632 ms 10008 KB Output is correct
4 Correct 655 ms 10260 KB Output is correct
5 Correct 558 ms 6332 KB Output is correct
6 Correct 722 ms 10096 KB Output is correct
7 Correct 746 ms 10072 KB Output is correct
8 Correct 596 ms 10064 KB Output is correct
9 Correct 332 ms 2896 KB Output is correct
10 Correct 661 ms 3152 KB Output is correct
11 Correct 611 ms 3152 KB Output is correct
12 Correct 518 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2768 KB Output is correct
7 Correct 2 ms 2808 KB Output is correct
8 Correct 2 ms 2768 KB Output is correct
9 Correct 2 ms 2768 KB Output is correct
10 Correct 2 ms 2768 KB Output is correct
11 Correct 2 ms 2768 KB Output is correct
12 Correct 2 ms 2724 KB Output is correct
13 Correct 432 ms 6396 KB Output is correct
14 Correct 617 ms 10056 KB Output is correct
15 Correct 632 ms 10008 KB Output is correct
16 Correct 655 ms 10260 KB Output is correct
17 Correct 558 ms 6332 KB Output is correct
18 Correct 722 ms 10096 KB Output is correct
19 Correct 746 ms 10072 KB Output is correct
20 Correct 596 ms 10064 KB Output is correct
21 Correct 332 ms 2896 KB Output is correct
22 Correct 661 ms 3152 KB Output is correct
23 Correct 611 ms 3152 KB Output is correct
24 Correct 518 ms 3152 KB Output is correct
25 Correct 677 ms 14728 KB Output is correct
26 Correct 815 ms 14964 KB Output is correct
27 Correct 856 ms 14864 KB Output is correct
28 Correct 554 ms 14964 KB Output is correct
29 Correct 881 ms 18056 KB Output is correct
30 Correct 653 ms 18012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2768 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 1 ms 2768 KB Output is correct
15 Correct 2 ms 2808 KB Output is correct
16 Correct 2 ms 2768 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2724 KB Output is correct
21 Incorrect 2 ms 2768 KB 1st lines differ - on the 1st token, expected: '759476520', found: '833967706'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2768 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 1 ms 2768 KB Output is correct
15 Correct 2 ms 2808 KB Output is correct
16 Correct 2 ms 2768 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2724 KB Output is correct
21 Incorrect 2 ms 2768 KB 1st lines differ - on the 1st token, expected: '759476520', found: '833967706'
22 Halted 0 ms 0 KB -