답안 #1016018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016018 2024-07-07T09:54:10 Z May27_th Relativnost (COCI15_relativnost) C++17
28 / 140
3278 ms 44364 KB
#include<bits/stdc++.h>
using namespace std;
#define i64 long long
#define i128 __int128
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
const int MOD = 10007;
int C;
void Add(int &x, int y) {
  x = (x + y);
  if (x > MOD) x -= MOD;
}
struct Tree {
  int N; 
  vector<vector<int>> st;
  Tree (int _N) : N(_N), st(_N * 4 + 4) {
    for (int i = 1; i <= 4 * N + 3; i ++) {
      st[i].resize(C + 2, 0);
    }
  }
  vector<int> combine(vector<int> L, vector<int> R) {
    vector<int> res(C + 2, 0);
    for (int i = 0; i <= C; i ++) {
      for (int j = 0; j <= C; j ++) {
        Add(res[min(i + j, C)], L[i] * R[j] % MOD);
      }
    }
    return res;
  };
  void update(int id, int l, int r, int p, pair<int, int> x) {
    if (p < l || p > r) return;
    if (l == r) {
      st[id][0] = x.second;
      st[id][1] = x.first;
      return;
    }
    int mid = (l + r)/2;
    update(id * 2, l, mid, p, x);
    update(id * 2 + 1, mid + 1, r, p, x);
    st[id] = combine(st[id * 2], st[id * 2 + 1]);
  }
};
void Solve(void) {
  int N; cin >> N >> C;
  vector<pair<int, int>> p(N);
  for (int i = 0; i < N; i ++) cin >> p[i].first;
  for (int i = 0; i < N; i ++) cin >> p[i].second;  
  Tree T(N);
  for (int i = 0; i < N; i ++) {
    p[i].first %= MOD;
    p[i].second %= MOD;
    T.update(1, 1, N, i + 1, p[i]);
  }
  // cout << T.st[1].f[C] << "\n";
  int Q; cin >> Q; while (Q --) {
    int p, A, B; cin >> p >> A >> B;
    T.update(1, 1, N, p, mp(A, B));
    cout << T.st[1][C] << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(10);
  int Tests = 1; // cin >> Tests;
  while (Tests --) {
    Solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 604 KB Output is correct
2 Correct 11 ms 604 KB Output is correct
3 Incorrect 21 ms 796 KB Output isn't correct
4 Incorrect 490 ms 15880 KB Output isn't correct
5 Runtime error 1807 ms 36524 KB Memory limit exceeded
6 Runtime error 2774 ms 44364 KB Memory limit exceeded
7 Incorrect 989 ms 22984 KB Output isn't correct
8 Incorrect 647 ms 26904 KB Output isn't correct
9 Incorrect 924 ms 27060 KB Output isn't correct
10 Runtime error 3278 ms 34824 KB Memory limit exceeded