Submission #870407

# Submission time Handle Problem Language Result Execution time Memory
870407 2023-11-07T20:52:56 Z Nonoze Digital Circuit (IOI22_circuit) C++17
Compilation error
0 ms 0 KB
#include "circuit.h"
#include "stub.cpp"

#include <bits/stdc++.h>
using namespace std;
const long long MOD= 1000002022;


vector<int> a;
vector<int> adj[100005];
int n, m;

pair<long long, long long> dfs(int s) {
	if (s>=n) {
		return {a[s-n], a[s-n]^1};
	}
	long long comp=0;
	vector<long long> dp(adj[s].size()+1, 0);
	dp[0]=1;
	for (auto u: adj[s]) {
		auto act=dfs(u);
		for (int i=dp.size()-1; i>=0; i--) {
			dp[i]*=act.second;
			if (i>0) {
				dp[i]+=dp[i-1]*act.first;
			}
			dp[i]%=MOD;
		}
	}
	for (int i=1; i<(int)dp.size()-1; i++) {
		comp+=dp[i]*i;
	}
	comp=(comp+10*MOD)%MOD;
	long long sz=adj[s].size();
	return {
		(comp+(dp.back()*sz)%MOD)%MOD,
		(comp+(dp[0]*sz)%MOD)%MOD
	};
}

void init(int N, int M, vector<int> p, vector<int> aa) {
	a=aa;
	n=N, m=M; 
	for (int i=1; i<n+m; i++) {
		adj[p[i]].push_back(i);
	}
}

int count_ways(int L, int R) {
	for (int i=L; i<=R; i++) {
		a[i-n]^=1;
	}
	return dfs(0).first;
}

Compilation message

/usr/bin/ld: /tmp/cc04uEaa.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cce3Ifta.o:circuit.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status