QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#150647#4564. Digital Circuitjuanda_o_1822 2ms3792kbC++231.6kb2023-08-25 22:56:562023-08-25 22:56:59

Judging History

你现在查看的是最新测评结果

  • [2023-08-25 22:56:59]
  • 评测
  • 测评结果:2
  • 用时:2ms
  • 内存:3792kb
  • [2023-08-25 22:56:56]
  • 提交

answer

#include "circuit.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long 

ll n,m,on;
vector<ll>p;
vector<ll>a;
vector<vector<ll>>inputs;

void init(int N, int M, vector<int> P, vector<int> A) {
	n=N;
	m=M;
	vector<ll>in;
	//in.push_back(0);
	for(int i=0;i<n;i++){
		inputs.push_back(in);
		a.push_back(0);
	}
	for(int i=0;i<int(P.size());i++){
		p.push_back(P[i]);
		if(p[i]!=-1){
			inputs[p[i]].push_back(i);
		}
	}
	for(int i=0;i<int(A.size());i++){
		a.push_back(A[i]);
		if(A[i]==1){
			on+=1;
		}
	}
}
ll sourceOn(ll n,ll num,vector<ll>source){
	ll on=0;
	/*
	//print parameters
	cout<<n<<"=n"<<endl;
	cout<<num<<"=num"<<endl;
	for(int i=0;i<int(source.size());i++){
		cout<<source[i]<<" ";
	}
	cout<<"=source"<<endl;
	*/
	for(int i=0;i<int(source.size());i++){
		if(a[source[i]]==1){
			on+=1;
		}
	}
	if(on!=0 and (num-1)>=0){
		a[num]=1;
	}else{
		a[num]=0;
	}
	return on;
}

ll num;
int count_ways(int L, int R) {
	ll ans=0;
	for(int i=L;i<R+1;i++){
		if(a[i]==0){
			a[i]=1;
		}else{
			a[i]=0;
		}
	}
	
	/*
	//print state
	cout<<"[";
	for(int i=0;i<int(a.size());i++){
		cout<<a[i]<<",";
	}
	cout<<"states]"<<endl;
	 
	//print inputs
	cout<<"[";
	for(int i=0;i<int(inputs.size());i++){
		cout<<"[";
		for(int j=0;j<int(inputs[i].size());j++){
			cout<<inputs[i][j]<<",";
		}
		cout<<"ind],";
	}
	cout<<"inputs]"<<endl;
	*/
	for(int i=n-1;i>=0;i--){
		num=sourceOn(n,i,inputs[i]);
		if(num>0 and ans!=0){
			ans*=num;
		}else if(ans==0 and num>0){
			ans=num;
		}
	}
	
	
	return ans;
}

详细

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 2ms
memory: 3644kb

input:

1 2
-1 0 0
0 0
1 1
2 2
1 2
2 2
1 2
-1 -1
-2 -2

output:

1
2
0
1
1

result:

ok 7 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

1 1
-1 0
0
1 1
1 1
1 1
1 1
-1 -1
-2 -2

output:

1
0
1
0

result:

ok 6 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 3792kb

input:

1 972
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

509
483
489
500
481

result:

ok 7 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

1 1000
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

4
40
428
262
237

result:

ok 7 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

1 1000
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

898
828
828
617
582

result:

ok 7 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

1 1000
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

535
494
500
498
509

result:

ok 7 lines

Test #7:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

1 1000
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

517
486
511
487
512

result:

ok 7 lines

Test #8:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

1 1000
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

501
500
499
500
501

result:

ok 7 lines

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 7
Accepted
time: 1ms
memory: 3656kb

input:

1 2
-1 0 0
0 0
1 1
2 2
1 2
2 2
1 2
-1 -1
-2 -2

output:

1
2
0
1
1

result:

ok 7 lines

Test #10:

score: -7
Wrong Answer
time: 0ms
memory: 3772kb

input:

255 256
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...

output:

0
0
32

result:

wrong answer 3rd lines differ - expected: '52130940', found: '0'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #43:

score: 0
Time Limit Exceeded

input:

32767 32768
-1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...

output:

131072
65536
131072
262144
524288
262144
131072
262144
131072
262144
524288
262144
131072
65536
32768
16384
32768
65536
131072
65536
32768
65536
131072
262144
524288
262144
131072
65536
32768
16384
8192
4096
8192
16384
8192
4096
2048
4096
2048
4096
2048
4096
2048
4096
8192
4096
8192
4096
8192
16384
...

result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%