Submission #746068

# Submission time Handle Problem Language Result Execution time Memory
746068 2023-05-21T10:59:50 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
2 ms 232 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod=1000000007;


int binpow(int a, int b){
	int ans = 1;
	while(b != 0){
		if(b % 2 == 1){
			ans=(ans*a)%mod;
		}
		a=(a*a) % mod;
		b/=2;
	}
	return ans;
}

int f(int wossz, int hossz){
	//return (((((hossz*(hossz+1)/2)%mod) * wossz)%mod)*(wossz+1)/2)%mod;
	return (((((hossz*(hossz+1)%mod*binpow(2, mod-2))%mod) * wossz)%mod)*(wossz+1)%mod*binpow(2, mod-2)%mod)%mod;
}

int32_t main() {
	// all hi are equal --> téglalap
	int s;
	cin>>s;
	int h[s];
	int w[s];
	int wossz = 0;
	bool teglalap = true, lepcso = true;
	for (int i=0; i<s; i++){
		cin >> h[i];
		if (h[i] != h[0]) teglalap = false;
		if (i != 0 && h[i] < h[i-1]) lepcso = false;
	}
	int hossz = h[0];
	for(int i=0; i<s; i++){
		cin>>w[i];
		wossz = (w[i] + wossz) % mod;
	}
	
	/*if (teglalap){
		cout << f(wossz, hossz);
		return 0;
	}
	
	// --------------- lépcső -----------------
	if (lepcso){
	int ans = f(wossz, h[0]);
	wossz = (wossz - w[0])%mod;
	for (int i=1; i<s; i++){
		ans = (ans + f((wossz+mod)%mod, h[i]))%mod;
		ans =  (ans - f((wossz+mod)%mod, h[i-1]))%mod;
		wossz = (wossz - w[i])%mod; 
	}
	ans=(ans+mod)%mod;
	cout << ans<<"\n";
	return 0;
	}*/
	//--------------- felváltva ----------------
	int db = 0;
	int ans = f(wossz, 1);
	//cout << ans << ". ";
	for (int i=0; i<s; i++){
		if (h[i] == 2) db += w[i];
		else{
			ans = (ans + f(db, 2)) %mod;
			ans = (ans - f(db, 1))%mod;
			db = 0;
		}
	}
	cout << ans;

	return 0;
}

Compilation message

fancyfence.cpp: In function 'int32_t main()':
fancyfence.cpp:32:7: warning: variable 'teglalap' set but not used [-Wunused-but-set-variable]
   32 |  bool teglalap = true, lepcso = true;
      |       ^~~~~~~~
fancyfence.cpp:32:24: warning: variable 'lepcso' set but not used [-Wunused-but-set-variable]
   32 |  bool teglalap = true, lepcso = true;
      |                        ^~~~~~
fancyfence.cpp:38:6: warning: unused variable 'hossz' [-Wunused-variable]
   38 |  int hossz = h[0];
      |      ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 232 KB Output isn't correct
2 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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 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 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 232 KB Output isn't correct
2 Halted 0 ms 0 KB -