Submission #697273

# Submission time Handle Problem Language Result Execution time Memory
697273 2023-02-09T04:24:37 Z kusssso Relativnost (COCI15_relativnost) C++17
0 / 140
4000 ms 13892 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int N = 1e5 + 5;
const int mod = 10007;
int n, c;
int q;
int a[N];
int b[N];

signed main() {
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      cin >> n >> c;
      for (int i = 1; i <= n; i++) cin >> a[i];
      for (int i = 1; i <= n; i++) cin >> b[i];
      cin >> q;
      while (q--) {
            int i, na, nb;
            cin >> i >> na >> nb;
            a[i] = na;
            b[i] = nb;
            vector<vi> dp(n + 2, vi (c + 2, 0));
            dp[0][0] = 1;
            ll total = 1;
            ll except = 0;
            for (int j = 1; j <= n; j++) {
                  total = total * (a[j] + b[j]) % mod;
                  for (int k = 0; k < c; k++) {
                        dp[j][k] += dp[j - 1][k] * b[j];
                        if (k > 0) 
                              dp[j][k] += dp[j - 1][k - 1] * a[j];
                        dp[j][k] %= mod;
                        if (j == n) {
                              except = (except + dp[j][k]) % mod;
                        }
                  }
            }
            cout << total - except << '\n';
      }
      return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 416 KB Output isn't correct
2 Incorrect 80 ms 348 KB Output isn't correct
3 Incorrect 79 ms 424 KB Output isn't correct
4 Execution timed out 4018 ms 6120 KB Time limit exceeded
5 Execution timed out 4042 ms 12012 KB Time limit exceeded
6 Execution timed out 4056 ms 13892 KB Time limit exceeded
7 Execution timed out 4049 ms 7936 KB Time limit exceeded
8 Execution timed out 4086 ms 9460 KB Time limit exceeded
9 Execution timed out 4038 ms 9304 KB Time limit exceeded
10 Execution timed out 4086 ms 10832 KB Time limit exceeded