QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#150643#4564. Digital Circuitjuanda_o_182Compile Error//C++231.6kb2023-08-25 22:54:582023-08-25 22:54:59

Judging History

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

  • [2023-08-25 22:54:59]
  • 评测
  • [2023-08-25 22:54:58]
  • 提交

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(ll N, ll M, vector<ll> P, vector<ll> 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;
ll count_ways(ll L, ll 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;
}

详细

/usr/bin/ld: /tmp/ccU8aDBL.o: in function `main':
implementer.cpp:(.text.startup+0x137): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: implementer.cpp:(.text.startup+0x168): undefined reference to `count_ways(int, int)'
collect2: error: ld returned 1 exit status