Submission #745901

# Submission time Handle Problem Language Result Execution time Memory
745901 2023-05-21T09:28:58 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;


int main(){
    int n; cin >> n;
    int x, e, hossz;
    int ans = 0;
    vector<int> w, h;
    int wsum = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        h.push_back(x);
    }

    for(int i = 0; i < n; i++){
        cin >> x;
        wsum += x;
        w.push_back(x);
    }

    hossz = h[0]*w[0];
    for(int i = 1; i < n; i++){
        if(h[i] == 1){
            hossz += w[i];
        }
        else if(h[i-1] == 1){
    //        cout << hossz << " ";
            ans += hossz*(hossz+1);
            ans = ans % 1000000007;
            hossz = 0;
        }
    }
    ans += hossz*(hossz+1); 
    ans = ans % 1000000007;
    
    ans += wsum*(wsum+1)/2;
    ans = ans % 1000000007;

    cout << ans;
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:7:12: warning: unused variable 'e' [-Wunused-variable]
    7 |     int x, e, hossz;
      |            ^
# 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 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 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 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -