Submission #945294

# Submission time Handle Problem Language Result Execution time Memory
945294 2024-03-13T15:45:32 Z bngybongybrd Fancy Fence (CEOI20_fancyfence) C++17
13 / 100
13 ms 3164 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n;
int w[100005];
int h[100005];
int ans = 0;
int width = 0;
int mod = 1000000000 + 7;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    for(int i = 0; i < n; i++)cin >> h[i];
        for(int i = 0; i < n; i++){
        cin >> w[i];
        width += w[i];
        width %= mod;
        // ans += (h[i]-1)*w[i]; // vertical rectangle for h=2
    }
    // cout << width << "\n";
    // cout << ans << "\n";
    if(width % 2 == 0){ // all rectangle for h=1
        ans += ((width+1)*(width/2))%mod;
        ans %= mod;
    } else {
        ans += ((width*(width-1)/2)+width)%mod;
        ans %= mod;
    }
    // cout << ans << "\n";
    width = 0;
    for(int i = 0; i < n; i++){
        if(h[i] > 1){
            width += w[i];
            width %= mod;
        } else {
            if(width != 0){
                if(width % 2 == 0){ // all rectangle for h=2
                    ans += ((width+1)*(width/2)*2)%mod;
                    ans %= mod;
                } else {
                    ans += (((width*(width-1)/2)+width)*2)%mod;
                    ans %= mod;
                }
            }
            width = 0;
        }
        if(i == (n-1)){
            if(width != 0){
                if(width % 2 == 0){ // all rectangle for h=2
                    ans += ((width+1)*(width/2)*2)%mod;
                    ans %= mod;
                } else {
                    ans += (((width*(width-1)/2)+width)*2)%mod;
                    ans %= mod;
                }
            }
            width = 0;
        }
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 9 ms 1628 KB Output is correct
4 Correct 13 ms 3164 KB Output is correct
5 Correct 12 ms 3160 KB Output is correct
6 Correct 12 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -