Submission #362444

# Submission time Handle Problem Language Result Execution time Memory
362444 2021-02-03T09:27:04 Z Bill_00 Remittance (JOI19_remittance) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define M 1000001
typedef long long ll;
const int p=53;
const long long MOD=1000000007;
using namespace std;
ll a[M],b[M],c[M],d[M],n;
ll pow2[M];
ll power(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1){
			res=res*a;
			if(res>=MOD) res%=MOD;
		}
		b>>=1;
		a=a*a;
		if(a>=MOD) a%=MOD;
	}
	return res;
}
ll turn(ll k){
	return (k+10*MOD)%MOD;
}
ll suma,sumb,sumgiven;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	pow2[0]=1;
	for(int i=1;i<=n;i++){
		pow2[i]=pow2[i-1]*2;
		if(pow2[i]>=MOD) pow2[i]%=MOD;
	}
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		suma+=a[i];
		sumb+=b[i];
		c[i]=a[i]-b[i];
	}
	long long res=0;
	for(int i=1;i<n;i++){
		res+=((turn(c[i])*pow2[i-1])%MOD);
		if(res>=MOD) res%=MOD;
	}
	bool f=0;	
	res+=((c[0]*pow2[n-1])%MOD);
	if(res>=MOD) res%=MOD;
	res=res*power(pow2[n]-1,MOD-2);
	if(res>=MOD) res%=MOD;
	d[0]=res;
	sumgiven=d[0];
	for(int i=1;i<n;i++){
		ll e=c[i]+d[i-1];
		if(e&1){
			cout << "No";
			return 0;
		}
		d[i]=e/2;
		sumgiven+=(d[i]);
		if(d[i]<0){
			cout << "No";
			return 0;
		}
		if(d[i-1]+a[i]<2*d[i]){
			cout << "No";
			return 0;
		}
		if(a[i]>=2*d[i]) f=1;
	}
	if(d[n-1]+a[0]<2*d[0]){
		cout << "No";
		return 0;
	}
	if(c[0]-2*d[0]+d[n-1]!=0){
		cout << "No";
		return 0;
	}
	if(sumgiven+sumb!=suma){
		cout << "No";
		return 0;
	}
	if(f==0){
		cout << "No";
		return 0;
	}
	for(int i=0;i<n;i++){
		int e=a[i]/2;
		e=min(e,d[i]);
		a[i]-=(2*e);
		d[i]-=e;
		if(i==(n-1)) a[0]+=e;
		else a[i+1]+=e;
	}
	for(int i=0;i<n;i++){
		int e=a[i]/2;
		e=min(e,d[i]);
		a[i]-=(2*e);
		d[i]-=e;
		if(i==(n-1)) a[0]+=e;
		else a[i+1]+=e;
	}
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";



}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:93:15: error: no matching function for call to 'min(int&, ll&)'
   93 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
remittance.cpp:93:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   93 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
remittance.cpp:93:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   93 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
remittance.cpp:93:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   93 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
remittance.cpp:93:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   93 |   e=min(e,d[i]);
      |               ^
remittance.cpp:101:15: error: no matching function for call to 'min(int&, ll&)'
  101 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
remittance.cpp:101:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  101 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
remittance.cpp:101:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  101 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
remittance.cpp:101:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  101 |   e=min(e,d[i]);
      |               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from remittance.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
remittance.cpp:101:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  101 |   e=min(e,d[i]);
      |               ^