답안 #791556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791556 2023-07-24T07:23:38 Z WongChun1234 디지털 회로 (IOI22_circuit) C++17
컴파일 오류
0 ms 0 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200050;
const ll MOD=1000002022;
int n,m,lz[N<<2];
ll dp[N],rdp[N],seg[N<<2],iseg[N<<2];
vector<ll> p,a,ch[N],pref[N],suff[N];
void build(int id,int l,int r){
	if (l==r){
		seg[id]=a[l-1]*rdp[l+n-1];
		iseg[id]=(!a[l-1])*rdp[l+n-1];
		//cout<<id<<" "<<l<<" "<<r<<" "<<seg[id]<<" "<<iseg[id]<<"\n";
		return;
	}
	int m=(l+r)/2;
	build(id*2,l,m);
	build(id*2+1,m+1,r);
	seg[id]=(seg[id*2]+seg[id*2+1])%MOD;
	iseg[id]=(iseg[id*2]+iseg[id*2+1])%MOD;
	//cout<<id<<" "<<l<<" "<<r<<" "<<seg[id]<<" "<<iseg[id]<<"\n";
}
void pushdown(int id){
	lz[id]^=1;
	swap(seg[id],iseg[id]);
}
void update(int id,int l,int r,int ql,int qr){
	if (l>=ql&&r<=qr){
		pushdown(id);
		return;
	}
	if (l>qr||r<ql) return;
	if (lz[id]){
		pushdown(id*2);
		pushdown(id*2+1);
		lz[id]=0;
	}
	int m=(l+r)/2;
	update(id*2,l,m,ql,qr);
	update(id*2+1,m+1,r,ql,qr);
	seg[id]=(seg[id*2]+seg[id*2+1])%MOD;
	iseg[id]=(iseg[id*2]+iseg[id*2+1])%MOD;
}
void init(int N, int M, vector<int> P, vector<int> A) {
	n=N,m=M,p=P,a=A;
	for (int i=1;i<n+m;i++) ch[p[i]].push_back(i);
	for (int i=n+m-1;i>=n;i--){
		dp[i]=1;
	}
	for (int i=n-1;i>=0;i--){
		pref[i].push_back(1),suff[i].push_back(1);
		for (int j:ch[i]) pref[i].push_back(dp[j]),suff[i].push_back(dp[j]);
		pref[i].push_back(1),suff[i].push_back(1);
		for (int j=1;j<=ch[i].size();j++) pref[i][j]=pref[i][j-1]*pref[i][j]%MOD;
		for (int j=ch[i].size();j>=1;j--) suff[i][j]=suff[i][j+1]*suff[i][j]%MOD;
		dp[i]=suff[i][1]*ch[i].size()%MOD;
	}
	rdp[0]=1;
	for (int i=0;i<n;i++){
		for (int j=1;j<=ch[i].size();j++) rdp[ch[i][j-1]]=rdp[i]*(pref[i][j-1]*suff[i][j+1]%MOD)%MOD;
	}
	//for (int i=0;i<n+m;i++) cout<<dp[i]<<" "<<rdp[i]<<"\n";
	build(1,1,m);
}

int count_ways(int L, int R) {
	update(1,1,m,L-n+1,R-n+1);
	return seg[1];
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:46:12: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   46 |  n=N,m=M,p=P,a=A;
      |            ^
In file included from /usr/include/c++/10/vector:72,
                 from circuit.h:1,
                 from circuit.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from circuit.h:1,
                 from circuit.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
circuit.cpp:46:16: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   46 |  n=N,m=M,p=P,a=A;
      |                ^
In file included from /usr/include/c++/10/vector:72,
                 from circuit.h:1,
                 from circuit.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from circuit.h:1,
                 from circuit.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
circuit.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for (int j=1;j<=ch[i].size();j++) pref[i][j]=pref[i][j-1]*pref[i][j]%MOD;
      |                ~^~~~~~~~~~~~~~
circuit.cpp:61:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for (int j=1;j<=ch[i].size();j++) rdp[ch[i][j-1]]=rdp[i]*(pref[i][j-1]*suff[i][j+1]%MOD)%MOD;
      |                ~^~~~~~~~~~~~~~