Submission #580212

# Submission time Handle Problem Language Result Execution time Memory
580212 2022-06-20T17:57:17 Z MODDI Fancy Fence (CEOI20_fancyfence) C++14
28 / 100
82 ms 4520 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;
	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;
		}
	}
	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;
	}
	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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 26 ms 1348 KB Output is correct
4 Correct 51 ms 2564 KB Output is correct
5 Correct 52 ms 2632 KB Output is correct
6 Correct 53 ms 2632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 9 ms 712 KB Output is correct
3 Correct 38 ms 2308 KB Output is correct
4 Correct 78 ms 4292 KB Output is correct
5 Correct 78 ms 4520 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 11 ms 724 KB Output is correct
4 Correct 40 ms 2372 KB Output is correct
5 Correct 76 ms 4320 KB Output is correct
6 Correct 82 ms 4412 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -