Submission #720375

# Submission time Handle Problem Language Result Execution time Memory
720375 2023-04-08T05:50:04 Z ismayil Digital Circuit (IOI22_circuit) C++17
0 / 100
10 ms 2504 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int MAX = 3e3;
ll dp[2][MAX];
vector<ll> adj[MAX];
ll 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;
	ll l = -1, r = -1;
	for(auto v : adj[u]){
		dfs(v);
		if(l == -1) l = v;
		else r = v;
	}
	if(l == -1 || r == -1) return;
	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 0 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 0 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 2504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2504 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 0 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 0 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -