Submission #372241

# Submission time Handle Problem Language Result Execution time Memory
372241 2021-02-27T10:06:58 Z gustason Travels (LMIO17_keliones) C++14
45 / 100
104 ms 25564 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
signed 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]);
            sum[j] %= mod;
        }
    }

    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 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 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 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 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 Correct 15 ms 620 KB Output is correct
14 Correct 15 ms 1260 KB Output is correct
15 Correct 13 ms 1132 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 13 ms 1132 KB Output is correct
18 Correct 8 ms 876 KB Output is correct
19 Correct 2 ms 620 KB Output is correct
20 Correct 1 ms 620 KB Output is correct
21 Correct 1 ms 620 KB Output is correct
22 Correct 1 ms 620 KB Output is correct
23 Correct 2 ms 620 KB Output is correct
24 Correct 2 ms 748 KB Output is correct
25 Correct 1 ms 620 KB Output is correct
26 Correct 1 ms 620 KB Output is correct
27 Correct 4 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 620 KB Output is correct
2 Correct 15 ms 1260 KB Output is correct
3 Correct 13 ms 1132 KB Output is correct
4 Correct 5 ms 620 KB Output is correct
5 Correct 13 ms 1132 KB Output is correct
6 Correct 8 ms 876 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 0 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 102 ms 25500 KB Output is correct
29 Correct 79 ms 24684 KB Output is correct
30 Correct 88 ms 25068 KB Output is correct
31 Correct 96 ms 24684 KB Output is correct
32 Correct 76 ms 24684 KB Output is correct
33 Correct 76 ms 24812 KB Output is correct
34 Correct 87 ms 25068 KB Output is correct
35 Correct 97 ms 25452 KB Output is correct
36 Correct 104 ms 25564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 620 KB Output is correct
2 Correct 15 ms 1260 KB Output is correct
3 Correct 13 ms 1132 KB Output is correct
4 Correct 5 ms 620 KB Output is correct
5 Correct 13 ms 1132 KB Output is correct
6 Correct 8 ms 876 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 102 ms 25500 KB Output is correct
17 Correct 79 ms 24684 KB Output is correct
18 Correct 88 ms 25068 KB Output is correct
19 Correct 96 ms 24684 KB Output is correct
20 Correct 76 ms 24684 KB Output is correct
21 Correct 76 ms 24812 KB Output is correct
22 Correct 87 ms 25068 KB Output is correct
23 Correct 97 ms 25452 KB Output is correct
24 Correct 104 ms 25564 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 0 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Runtime error 26 ms 5356 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -