Submission #995377

# Submission time Handle Problem Language Result Execution time Memory
995377 2024-06-09T01:03:47 Z aaaaaarroz Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 4184 KB
#include <bits/stdc++.h>
using namespace std;
int mod=1000002022;
vector<vector<int>>graph;
vector<int>max_parameter;
vector<int>ways;
vector<int>state;
int n,m;
void dfs1(int nodo){
	if(nodo>=n){
		return;
	}
	for(int vecino:graph[nodo]){
		dfs1(vecino);
		if(vecino<n){
			max_parameter[nodo]+=(max_parameter[vecino]>=1);
		}
		else{
			max_parameter[nodo]+=(state[vecino-n]==1);
		}
	}
}
void dfs2(int nodo){
	if(nodo<n){
		ways[nodo]=max_parameter[nodo];
	}
	for(int vecino:graph[nodo]){
		dfs2(vecino);
		(ways[nodo]*=ways[vecino])%=mod;
	}
}
void init(int N, int M, vector<int> P, vector<int> A) {
	n=N;
	m=M;
	graph.resize(N+M,vector<int>());
	state=A;
	max_parameter.resize(N);
	ways.resize(N+M);
	for(int i=0;i<P.size();i++){
		if(P[i]!=-1){
			graph[P[i]].push_back(i);
		}
	}
}

int count_ways(int L, int R) {
  for(int i=L;i<=R;i++){
	  state[i-n]^=1;
  }
  dfs1(0);
  ways.resize(n+m,1);
  dfs2(0);
  return ways[0];
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0;i<P.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -