Submission #910875

# Submission time Handle Problem Language Result Execution time Memory
910875 2024-01-18T08:42:19 Z tnun Digital Circuit (IOI22_circuit) C++17
0 / 100
26 ms 19088 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int N,M;
vector<int> P;
vector<int> A;
ll int mod=1000002022;
vector<int> adj[200050];
ll int one[200050]={0};
ll int zer[200050]={0};
void dfs(int node){
	if(node>=N){
		if(A[node-N]==1){
			one[node]=1;
			zer[node]=0;
		}else{
			one[node]=0;
			zer[node]=1;
		}
		return;
	}
	for(int i=0;i<adj[node].size();i++){
		dfs(adj[node][i]);
	}
	ll int all=1;
	for(int i=0;i<adj[node].size();i++){
		all*=(one[adj[node][i]]+zer[adj[node][i]]);
		all=all%mod;
	}
	for(int i=0;i<adj[node].size();i++){
		one[node]+=(one[adj[node][i]])*all/(one[adj[node][i]]+zer[adj[node][i]]);
		one[node]=one[node]%mod;
	}
	zer[node]=all-one[node];
}
int count_ways(int l,int r){
	memset(one, 0, sizeof(one));
	memset(zer, 0, sizeof(zer));
	int visited[N+M+1]={0};
	for(int i=l-1;i<r;i++){
		A[i]=(A[i]+1)%2;
	}
	dfs(0);
	return one[0];
}
void init(int N,int M, vector<int> P,vector<int> A){
	for(int i=1;i<N+M;i++){
		adj[P[i]].pb(i);
	}
}

Compilation message

circuit.cpp: In function 'void dfs(int)':
circuit.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<adj[node].size();i++){
      |              ~^~~~~~~~~~~~~~~~~
circuit.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0;i<adj[node].size();i++){
      |              ~^~~~~~~~~~~~~~~~~
circuit.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=0;i<adj[node].size();i++){
      |              ~^~~~~~~~~~~~~~~~~
circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:40:6: warning: unused variable 'visited' [-Wunused-variable]
   40 |  int visited[N+M+1]={0};
      |      ^~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 16216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 16192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 16216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 19088 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 19088 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 16192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 16216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 16216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -