답안 #1042569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042569 2024-08-03T07:24:08 Z yanb 디지털 회로 (IOI22_circuit) C++17
0 / 100
9 ms 7376 KB
#include <bits/stdc++.h>
	
using namespace std;
	
#define int long long
	
int n, M;
vector<int> p, a;
vector<vector<int>> ch;

vector<int> conv(vector<signed> v) {
	vector<int> ans(n);
	for (int i = 0; i < n; i++) ans[i] = v[i];
	return ans;
}

void init(signed n_, signed M_, vector<signed> p_, vector<signed> a_) {
	n = n_, M = M_, p = conv(p_), a = conv(a_);
	ch.resize(n + M);
	for (int i = 1; i < n + M; i++) {
		ch[p[i]].push_back(i);
	}
}

int count_ways(signed l, signed r) {
	for (int i = l; i <= r; i++) {
		a[i] = !a[i];
	}

	vector<int> on(n + M), off(n + M);
	for (int i = n; i < n + M; i++) {
		if (a[i]) on[i] = 1;
		else off[i] = 1;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (ch[i].size() == 1) {
			on[i] = on[ch[i][0]];
			off[i] = off[ch[i][0]];
		} else {
			int x1 = on[ch[i][0]], y1 = off[ch[i][0]], x2 = on[ch[i][1]], y2 = off[ch[i][1]];
			on[i] = (2 * x1 * x2 + x1 * y2 + y1 * x2) % 1000002022;
			off[i] = (2 * y1 * y2 + x1 * y2 + y1 * x2) % 1000002022;
		}
	}

	return on[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 0 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 7376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 7376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 0 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -