#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(){
scanf("%d %d", &n, &c);
for(int i = 1; i <= n; i++){
scanf("%d %d", &a, &b);
a %= mod, b %= mod;
update(1, 1, n, i, a, b);
}
cin >> q;
while(q --){
scanf("%d %d %d", &x, &a, &b);
a %= mod, b %= mod;
update(1, 1, n, x, a, b);
cout << it[1].ret[c] << "\n";
}
}
Compilation message
relativnost.cpp: In function 'int main()':
relativnost.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &c);
~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &a, &b);
~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &x, &a, &b);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
512 KB |
Output isn't correct |
2 |
Incorrect |
15 ms |
512 KB |
Output isn't correct |
3 |
Incorrect |
36 ms |
512 KB |
Output isn't correct |
4 |
Incorrect |
723 ms |
11568 KB |
Output isn't correct |
5 |
Incorrect |
2306 ms |
22364 KB |
Output isn't correct |
6 |
Incorrect |
3561 ms |
22476 KB |
Output isn't correct |
7 |
Incorrect |
1470 ms |
11544 KB |
Output isn't correct |
8 |
Incorrect |
971 ms |
22008 KB |
Output isn't correct |
9 |
Incorrect |
1239 ms |
22264 KB |
Output isn't correct |
10 |
Execution timed out |
4050 ms |
22520 KB |
Time limit exceeded |