Submission #720371

# Submission time Handle Problem Language Result Execution time Memory
720371 2023-04-08T05:39:34 Z ismayil Digital Circuit (IOI22_circuit) C++17
0 / 100
10 ms 2416 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int MAX = 3e3;
int dp[2][MAX];
vector<int> adj[MAX];
int n, m;
void init(int N, int M, vector<int> P, vector<int> A) {
    n = N, m = M;
	for(int i = 0; i < N + M; i++){
		if(P[i] == -1) continue;
		adj[P[i]].push_back(i);
	}
    for(int i = 0; i < M; i++){
        dp[A[i]][i + n] = 1;
    }
}
void dfs(int u){
	if(u >= n) return;
	int l = -1, r = -1;
	for(auto v : adj[u]){
		dfs(v);
		if(l == -1) l = v;
		else r = v;
	}
	dp[0][u] = dp[0][l] * dp[1][r] + dp[1][l] * dp[0][r] + 2 * dp[0][l] * dp[0][r];
	dp[1][u] = dp[0][l] * dp[1][r] + dp[1][l] * dp[0][r] + 2 * dp[1][l] * dp[1][r];
}
int count_ways(int L, int R) {
	for(int i = L; i <= R; i++){
		dp[0][i] = 1 - dp[0][i];
		dp[1][i] = 1 - dp[1][i];
	}
	dfs(0);
	return dp[1][0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -