답안 #920056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920056 2024-02-02T02:47:05 Z TIN Relativnost (COCI15_relativnost) C++17
0 / 140
2669 ms 26540 KB
#include <bits/stdc++.h>

using namespace std;

#define FNAME "test"

const int M = 10007;
const int N = 1e5 + 5;
const short int C = 21;

int n, c, q;
int pos, vala, valb;
int a[N], b[N];

struct Node {
	int chosen[C];

	Node() {
		memset(chosen, 0, sizeof(chosen));
	}
} ST[3 * N];

Node merge(const Node& Node1, const Node& Node2) {
	Node nNode;
	for (int i = 0; i <= c; i++) {
		for (int j = 0; j <= c; j++) {
			nNode.chosen[min(c, i + j)] = (1LL * nNode.chosen[min(c, i + j)] + 1LL * Node1.chosen[i] * Node2.chosen[j]) % M;
		}
	}
	return nNode;
}

void Task() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(9);
	if (fopen(FNAME".inp","r")) {
		freopen(FNAME".inp","r",stdin);
		freopen(FNAME".out","w",stdout);
	}
}

void build(int id, int l, int r) {
	if (l == r) {
		ST[id].chosen[0] = b[l] % M;
		ST[id].chosen[1] = a[r] % M;
		return;
	}
	int m = (l + r) / 2;
	build(id * 2, l, m);
	build(id * 2 + 1, m + 1, r);
	ST[id] = merge(ST[id * 2], ST[id * 2 + 1]);
}

void update(int id, int l, int r, int pos, int vala, int valb) {
	if (pos < l || r < pos) return;
	if (l == r) {
		a[pos] = vala; ST[id].chosen[1] = a[pos] % M;
		b[pos] = valb; ST[id].chosen[0] = b[pos] % M;
		return;
	}
	int m = (l + r) / 2;
	if (pos <= m) update(id * 2, l, m, pos, vala, valb);
	else update(id * 2 + 1, m + 1, r, pos, vala, valb);
	ST[id] = merge(ST[id * 2], ST[id * 2 + 1]);
}

void Solve() {
	//Your Code
	cin >> n >> c;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	build(1, 1, n);
	cin >> q;
	while (q--) {
		cin >> pos >> vala >> valb;
		update(1, 1, n, pos, vala, valb);
		cout << ST[1].chosen[c] << '\n';
	}
}

signed main() {
	Task();
	Solve();
	cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms";
	return 37^37;
}

Compilation message

relativnost.cpp: In function 'void Task()':
relativnost.cpp:38:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   freopen(FNAME".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
relativnost.cpp:39:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   freopen(FNAME".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 25176 KB Output isn't correct
2 Incorrect 16 ms 25176 KB Output isn't correct
3 Incorrect 25 ms 25176 KB Output isn't correct
4 Incorrect 323 ms 25836 KB Output isn't correct
5 Incorrect 1116 ms 26540 KB Output isn't correct
6 Incorrect 1668 ms 26320 KB Output isn't correct
7 Incorrect 727 ms 26148 KB Output isn't correct
8 Incorrect 382 ms 25884 KB Output isn't correct
9 Incorrect 688 ms 25936 KB Output isn't correct
10 Incorrect 2669 ms 25992 KB Output isn't correct