답안 #910871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910871 2024-01-18T08:40:31 Z tnun 디지털 회로 (IOI22_circuit) C++17
컴파일 오류
0 ms 0 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));
	pair<ll int,ll int> l[N+M+1];
	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:28:39: error: invalid types 'int[int]' for array subscript
   28 |   all*=(one[adj[node][i]]+zer[adj[node[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:22: error: declaration of 'std::pair<long long int, long long int> l [((N + M) + 1)]' shadows a parameter
   40 |  pair<ll int,ll int> l[N+M+1];
      |                      ^
circuit.cpp:37:20: note: 'int l' previously declared here
   37 | int count_ways(int l,int r){
      |                ~~~~^
circuit.cpp:42:13: error: invalid conversion from 'std::pair<long long int, long long int>*' to 'int' [-fpermissive]
   42 |  for(int i=l-1;i<r;i++){
      |            ~^~
      |             |
      |             std::pair<long long int, long long int>*
circuit.cpp:41:6: warning: unused variable 'visited' [-Wunused-variable]
   41 |  int visited[N+M+1]={0};
      |      ^~~~~~~