Submission #98696

# Submission time Handle Problem Language Result Execution time Memory
98696 2019-02-25T04:53:17 Z Dat160601 Relativnost (COCI15_relativnost) C++17
0 / 140
4000 ms 22640 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 7, mod = 10007;

struct node{
	int ret[21];
} it[4 * N];

int n, c, q, a, b, x;

void add(int &a, int b){
	b %= mod;
	a += b;
	if(a >= mod) a -= mod;
}

node merge(node a, node b){
	node res;
	for(int i = 0; i <= c; i++) res.ret[i] = 0;
	for(int i = 0; i <= c; i++){
		for(int j = 0; j <= c; j++){
			add(res.ret[min(c, i + j)], a.ret[i] * b.ret[j]);
		}
	}
	return res;
}

void update(int k, int l, int r, int pos, int a, int b){
	if(l > pos || r < pos) return;
	if(l == r){
		it[k].ret[0] = b;
		it[k].ret[1] = a;
		return;
	}
	int mid = (l + r) >> 1;
	update(k << 1, l, mid, pos, a, b);
	update(k << 1 | 1, mid + 1, r, pos, a, b);
	it[k] = merge(it[k << 1], it[k << 1 | 1]);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> c;
	for(int i = 1; i <= n; i++){
		cin >> a >> b;
		update(1, 1, n, i, a, b);
	}
	cin >> q;
	while(q --){
		cin >> x >> a >> b;
		update(1, 1, n, x, a, b);
		cout << it[1].ret[c] << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 584 KB Output isn't correct
2 Incorrect 21 ms 484 KB Output isn't correct
3 Incorrect 32 ms 484 KB Output isn't correct
4 Incorrect 684 ms 11660 KB Output isn't correct
5 Incorrect 2222 ms 22424 KB Output isn't correct
6 Incorrect 3515 ms 22300 KB Output isn't correct
7 Incorrect 1478 ms 11640 KB Output isn't correct
8 Incorrect 1034 ms 22188 KB Output isn't correct
9 Incorrect 1321 ms 22616 KB Output isn't correct
10 Execution timed out 4019 ms 22640 KB Time limit exceeded