답안 #230576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230576 2020-05-10T13:13:46 Z ParsaAlizadeh Relativnost (COCI15_relativnost) C++17
0 / 140
475 ms 47736 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

template<class T = ll>
T nxt() {T x; cin >> x; return x;}

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const int N    = 1e5 + 10;
const int K    = 22;
const int MOD  = 10007;

int n, q, A[N], B[N], k, seg[N << 2][K];

void Merge(int id) {
    for (int i = 0; i <= k; i++) {
        seg[id][i] = 0;
    }
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            seg[id][min(k, i + j)] += seg[2 * id][i] * seg[2 * id + 1][j] % MOD;
            seg[id][min(k, i + j)] %= MOD;
        }
    }
}

void Build(int id, int l, int r) {
    if (r - l == 1) {
        seg[id][0] = B[l];
        seg[id][1] = A[l];
        return;
    }
    int mid = (l + r) >> 1;
    Build(2 * id, l, mid);
    Build(2 * id + 1, mid, r);
    Merge(id);
}

void Update(int id, int l, int r, int ind) {
    if (ind < l || r <= ind)
        return;
    if (r - l == 1) {
        seg[id][0] = B[l];
        seg[id][1] = A[l];
        return;
    }
    int mid = (l + r) >> 1;
    if (ind < mid)
        Update(2 * id, l, mid, ind);
    else
        Update(2 * id + 1, mid, r, ind);
    Merge(id);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(A[i])); A[i] %= MOD;
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &(B[i])); B[i] %= MOD;
    }
    Build(1, 0, n);
    scanf("%d", &q);
    while (q--) {
        int ind, a, b;
        cin >> ind >> a >> b; ind--;
        A[ind] = a % MOD;
        B[ind] = b % MOD;
        Update(1, 0, n, ind);
        printf("%d\n", seg[1][k]);
    }
    return 0;
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &(A[i])); A[i] %= MOD;
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:77:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &(B[i])); B[i] %= MOD;
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 512 KB Output isn't correct
2 Incorrect 14 ms 512 KB Output isn't correct
3 Incorrect 30 ms 512 KB Output isn't correct
4 Incorrect 475 ms 12580 KB Output isn't correct
5 Runtime error 163 ms 47736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 250 ms 47608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 105 ms 24568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 121 ms 47736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 112 ms 47352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 240 ms 47332 KB Execution killed with signal 11 (could be triggered by violating memory limits)