답안 #31686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31686 2017-08-31T10:46:15 Z buichitrung2001 Relativnost (COCI15_relativnost) C++14
0 / 140
0 ms 1840 KB
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;
const int   oo = 1e9 + 1;
const int  mod = 1e4 + 7;
const int maxn = 1e5 + 5;

int n, a, b, C, i, id, leaf[maxn], Q, u[maxn], t[maxn];

struct Node
{
    int f[21];
};
Node St[4 * maxn];

void Build (int id, int l, int r)
{
    if (i < l || i > r) return;
    if (l == r)
    {
        leaf[i] = id;
        St[id].f[0] = b % mod;
        St[id].f[1] = a % mod;
        return;
    }
    int mid = (l + r) / 2;
    Build (id * 2, l, mid);
    Build (id * 2 + 1, mid + 1, r);
}

void Merge (int id)
{
    Node res = {};
    for (int j = 0; j <= C; ++j)
        for (int l = 0; l <= C; ++l)
            res.f[min(C, l + j)] = (res.f[min(C, l + j)] + St[id * 2].f[j] * St[id * 2 + 1].f[l] % mod) % mod;
    St[id] = res;
}

void Init()
{
    cin >> n >> C;
    for (i = 1; i <= n; ++i) cin >> u[i];
    for (i = 1; i <= n; ++i) cin >> t[i];
    for (i = 1; i <= n; ++i)
    {
        a = u[i]; b = t[i];
        Build (1, 1, n);
    }
    for (i = 4 * n - 1; i >= 1; --i)
        if (St[i].f[0] == 0) Merge(i);
}

void Solve()
{
    cin >> Q;
    for (i = 1; i <= Q; ++i)
    {
        cin >> id >> a >> b;
        St[leaf[id]].f[0] = b % mod;
        St[leaf[id]].f[1] = a % mod;
        int u = leaf[id];
        while (true)
        {
            u = u / 2;
            if (u == 0) break;
            Merge (u);
        }
        cout << St[1].f[C] << '\n';
    }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("RELATIVNOST.inp", "r", stdin);
    //freopen("RELATIVNOST.out", "w", stdout);

	Init();
	Solve();
}
//Date 30 Month 8 Year 2017



# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)