답안 #910907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910907 2024-01-18T09:11:48 Z tnun 디지털 회로 (IOI22_circuit) C++17
2 / 100
3000 ms 10080 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(){
	for(int node=N+M-1;node>=0;node--){
	if(node>=N){
		if(A[node-N]==1){
			one[node]=1;
			zer[node]=0;
		}else{
			one[node]=0;
			zer[node]=1;
		}
		continue;
	}
	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;
	}
	all=all*adj[node].size();
	all=all%mod;
	zer[node]=all-one[node];
}
}
int count_ways(int l,int r){
	memset(one, 0, sizeof(one));
	memset(zer, 0, sizeof(zer));
	for(int i=l;i<=r;i++){
		A[i-N]=(A[i-N]+1)%2;
	}
//	for(int i=0;i<A.size();i++){
//		cout<<A[i]<<" ";
//	}
//	cout<<endl;
	dfs();
//	for(int i=0;i<N+M;i++){
//		cout<<i<<" "<<one[i]<<" "<<zer[i]<<endl;
//	}
	return one[0];
}
void init(int n,int m, vector<int> p,vector<int> a){
	N=n;
	M=m;
	for(int i=0;i<p.size();i++){
		P.pb(p[i]);
	}
	for(int i=0;i<a.size();i++){
		A.pb(a[i]);
	}
	for(int i=1;i<N+M;i++){
		adj[P[i]].pb(i);
	}
}

Compilation message

circuit.cpp: In function 'void dfs()':
circuit.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0;i<adj[node].size();i++){
      |              ~^~~~~~~~~~~~~~~~~
circuit.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0;i<adj[node].size();i++){
      |              ~^~~~~~~~~~~~~~~~~
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i=0;i<p.size();i++){
      |              ~^~~~~~~~~
circuit.cpp:60:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |  for(int i=0;i<a.size();i++){
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 3 ms 8280 KB Output is correct
4 Correct 3 ms 8532 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8280 KB Output is correct
8 Correct 3 ms 8224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Incorrect 3 ms 8280 KB 1st lines differ - on the 1st token, expected: '52130940', found: '113282342'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 3 ms 8280 KB Output is correct
4 Correct 3 ms 8532 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8280 KB Output is correct
8 Correct 3 ms 8224 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Incorrect 3 ms 8280 KB 1st lines differ - on the 1st token, expected: '52130940', found: '113282342'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3045 ms 10080 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3045 ms 10080 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Incorrect 3 ms 8280 KB 1st lines differ - on the 1st token, expected: '52130940', found: '113282342'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 3 ms 8280 KB Output is correct
4 Correct 3 ms 8532 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8280 KB Output is correct
8 Correct 3 ms 8224 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Incorrect 3 ms 8280 KB 1st lines differ - on the 1st token, expected: '52130940', found: '113282342'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 3 ms 8280 KB Output is correct
4 Correct 3 ms 8532 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8280 KB Output is correct
8 Correct 3 ms 8224 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Incorrect 3 ms 8280 KB 1st lines differ - on the 1st token, expected: '52130940', found: '113282342'
11 Halted 0 ms 0 KB -