Submission #580214

# Submission time Handle Problem Language Result Execution time Memory
580214 2022-06-20T18:00:38 Z MODDI Fancy Fence (CEOI20_fancyfence) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
const int MOD = 1e9 + 7;
int main(){
	int n;
	cin>>n;
	vl visina, sirina;
	bool all_same = true, sorted = true;
	for(int i = 0; i < n; i++){
		ll a;
		cin>>a;
		visina.pb(a);
		if(i > 0 && visina[i] != visina[i-1]){
			all_same = false;
		}
		if(i > 0 ** visina[i] < visina[i-1]){
			sorted = false;
		}
	}
	for(int i = 0; i < n; i++){
		ll a;
		cin>>a;
		sirina.pb(a);
	}
	ll rez = 0, cur = 0, sum = 0;
	if(all_same){
		ll vis = 0, sir = 0;
		for(int i = 0; i < n; i++){
			sir += sirina[i];
			sir %= MOD;
		}
		vis = visina[0];
		vis %= MOD;
		sir %= MOD;
		rez = sir * (sir + 1) / 2;
		rez %= MOD;
		ll rez2 = vis * (vis + 1) / 2;
		rez2 %= MOD;
		cout<<(rez*rez2)%MOD<<endl;
		return 0;
	}
	if(sorted){
		ll rez = 0, sir = 0;
		for(int i = 0; i < n; i++){
			sir += sirina[i];
			sir %= MOD;
		}
		for(int i = 0; i < n; i++){
			if(i == 0 || visina[i] != visina[i-1]){
				ll vis = visina[i];
				vis %= MOD;
				ll sega = sir*(sir + 1) / 2;
				sega %= 2;
				ll sega2 = vis *(vis + 1)/2;
				sega2%=MOD;
				rez += (sega *sega2)%MOD;
				rez %= MOD;
			}
			else
				continue;
		}
		cout<<rez%MOD<<endl;
		return 0;
	}
	for(int i = 0; i < n; i++){
		sum += sirina[i];
		sum %= MOD;
		if(visina[i] == 2)
		{
			cur += sirina[i];
			cur %= MOD;
		}
		else{
			if(cur > 0){
				rez += cur * (cur + 1);
				rez %= MOD;
				cur = 0;
			}
		}
	}
	if(cur > 0){
		rez += cur * (cur + 1);
		rez %= MOD;
	}
	rez += sum * (sum + 1) / 2;
	rez %= MOD;
	cout<<rez<<endl;
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:23:13: error: invalid type argument of unary '*' (have '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   23 |   if(i > 0 ** visina[i] < visina[i-1]){