Submission #447079

# Submission time Handle Problem Language Result Execution time Memory
447079 2021-07-24T12:04:19 Z Yahli Fancy Fence (CEOI20_fancyfence) C++14
0 / 100
186 ms 76788 KB
#include <bits/stdc++.h>
#define int long long

using namespace std; 
using pi = pair<int, int>; 

const int mod = 1e9+7; 
const int inv4 = 25e7+2; 

int calc(int a, int b){
    return ((a*(a+1)%mod)*(b*(b+1)%mod)%mod)*inv4%mod;
}

int req_solve(const vector<pi> & data, int n, int floor){
    if (n == 0) return 0; 

    //find the minimum: 
    int ind = 0, w = 0; 
    for (int i = 0; i < n; ++i){
        if (data[i].first < data[ind].first) ind = i; 
        w += data[i].second; 
    } 
    w %= mod; 

    int res = (calc(data[ind].first, w) - calc(floor, w) + mod) % mod;
    
    vector<pi> next; 
    for (int i = 0; i < n; ++i){
        if (data[i].first == data[ind].first){
            res = (req_solve(next, next.size(), data[ind].first) + res) % mod; 
            next.resize(0); 
        }
        else next.push_back(data[i]);
    }
    return (req_solve(next, next.size(), data[ind].first) + res) % mod; 
}

int32_t main(){
    freopen("input1.txt", "r", stdin); 
    int n; cin >> n;
    vector<pi> data(n); 
    for (int i = 0; i < n; ++i) cin >> data[i].first; 
    for (int i = 0; i < n; ++i) cin >> data[i].second; 
    cout << req_solve(data, n, 0); 
}

Compilation message

fancyfence.cpp: In function 'int32_t main()':
fancyfence.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     freopen("input1.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 76720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 76788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 167 ms 76728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 76720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 170 ms 76732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 186 ms 76732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 76720 KB Output isn't correct
2 Halted 0 ms 0 KB -