답안 #98701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98701 2019-02-25T05:05:17 Z Dat160601 Relativnost (COCI15_relativnost) C++17
112 / 140
4000 ms 23260 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;
int pa[N], pb[N];

void add(int &a, int b){
	a += b;
	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){
		for(int i = 0; i <= c; i++) it[k].ret[i] = 0;
		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", &pa[i]), pa[i] %= mod;
	for(int i = 1; i <= n; i++){
		scanf("%d", &pb[i]), pb[i] %= mod;
		update(1, 1, n, i, pa[i], pb[i]);
	}
	scanf("%d", &q);
	while(q --){
		scanf("%d %d %d", &x, &a, &b);
		a %= mod, b %= mod;
		update(1, 1, n, x, a, b);
		printf("%d\n", it[1].ret[c]);
	}
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:48: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:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i++) scanf("%d", &pa[i]), pa[i] %= mod;
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
relativnost.cpp:51:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &pb[i]), pb[i] %= mod;
   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
relativnost.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
relativnost.cpp:56: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 Correct 14 ms 512 KB Output is correct
2 Correct 22 ms 512 KB Output is correct
3 Correct 37 ms 512 KB Output is correct
4 Correct 700 ms 11872 KB Output is correct
5 Correct 2760 ms 23260 KB Output is correct
6 Execution timed out 4038 ms 23008 KB Time limit exceeded
7 Correct 1690 ms 12024 KB Output is correct
8 Correct 1074 ms 22748 KB Output is correct
9 Correct 1460 ms 23100 KB Output is correct
10 Execution timed out 4080 ms 22932 KB Time limit exceeded