Submission #372238

# Submission time Handle Problem Language Result Execution time Memory
372238 2021-02-27T10:05:36 Z gustason Travels (LMIO17_keliones) C++11
8 / 100
17 ms 1132 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> add(n);
    for(int i = 0; i < n; i++) {
        cin >> add[i];
    }

    bool adj[n][n];
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            adj[i][j] = true;
        }
    }
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a][b] = false;
    }

    vector<ll> cnt(n, 0), sum(n, 0);
    for(int i = 0; i < n; i++) {
        cnt[i] %= mod;
        ll cnts = (cnt[i] * add[i]) % mod;
        sum[i] += cnts;
        for(int j = i+1; j < n; j++) {
            if (!adj[i][j]) continue;
            cnt[j] += (cnt[i] + 1);
            cnt[j] %= mod;
            sum[j] += (sum[i] + add[i]);
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += sum[i];
        ans %= mod;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Incorrect 17 ms 1132 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -