답안 #98668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98668 2019-02-25T03:23:03 Z IOrtroiii Relativnost (COCI15_relativnost) C++14
0 / 140
49 ms 33792 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 100005;
const int C = 22;
const int mod = 10007;

int n, c;

struct Info {
	int d[C];
	Info() {
		memset(d, 0, sizeof d);
	}
	void upd(int a,int b) {
		d[0] = b % mod;
		d[1] = a % mod;
	}
	Info operator + (const Info &b) const {
		Info ans = Info();
		for (int i = 0; i <= c; ++i) {
			for (int j = 0; j <= c; ++j) {
				int &nd = ans.d[min(i + j, c)];
				nd += (d[i] * b.d[j]) % mod;
				if (nd >= mod) {
					nd -= mod;
				}
			}
		}
		return ans;
	}
};

int a[N], b[N];
Info t[N << 2];

void build(int v,int l,int r) {
	if (l == r) {
		t[v].upd(a[l], b[l]);
		return;
	}
	int md = (l + r) >> 1;
	build(v << 1, l, md);
	build(v << 1 | 1, md + 1, r);
	t[v] = t[v << 1] + t[v << 1 | 1];
}

void upd(int v,int l,int r,int p,int a,int b) {
	if (l == r) {
		t[v].upd(a, b);
		return;
	}
	int md = (l + r) >> 1;
	if (p <= md) {
		upd(v << 1, l, md, p, a, b);
	} else {
		upd(v << 1 | 1, md + 1, r, p, a, b);
	}
	t[v] = t[v << 1] + t[v << 1 | 1];
} 

int main() {
	
	scanf("%d %d", &n, &c);
	
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	} 
	
	for (int i = 1; i <= n; ++i) {
		scanf("%d", b + i);
	}
	
	int q;
	
	build(1, 1, n);
	scanf("%d", &q);
	while (q--) {
		int p, ap, bp;
		
		scanf("%d %d %d", &p, &ap, &bp);
		
		upd(1, 1, n, p, ap, bp);
		printf("%d\n", t[1].d[c]);
	}
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:67: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:70:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
   ~~~~~^~~~~~~~~~~~~
relativnost.cpp:74:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", b + i);
   ~~~~~^~~~~~~~~~~~~
relativnost.cpp:80:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
relativnost.cpp:84:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &p, &ap, &bp);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 49 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 48 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 39 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 41 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 49 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 39 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 48 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 38 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 44 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)