답안 #720377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720377 2023-04-08T06:01:51 Z ismayil 디지털 회로 (IOI22_circuit) C++17
컴파일 오류
0 ms 0 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int MAX = 3e3;
const int MOD = 1000002022
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;
	memset(dp, 0, sizeof(dp));
	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] % MOD + dp[1][l] * dp[0][r] % MOD + 2 * dp[0][l] * dp[0][r] % MOD) % MOD;
	dp[1][u] = (dp[0][l] * dp[1][r] % MOD + dp[1][l] * dp[0][r] % MOD + 2 * dp[1][l] * dp[1][r] % MOD) % MOD;
}
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];
}

Compilation message

circuit.cpp:3:12: error: expected ',' or ';' before 'long'
    3 | #define ll long long
      |            ^~~~
circuit.cpp:8:1: note: in expansion of macro 'll'
    8 | ll dp[2][MAX];
      | ^~
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:13:9: error: 'dp' was not declared in this scope
   13 |  memset(dp, 0, sizeof(dp));
      |         ^~
circuit.cpp: In function 'void dfs(int)':
circuit.cpp:31:2: error: 'dp' was not declared in this scope
   31 |  dp[0][u] = (dp[0][l] * dp[1][r] % MOD + dp[1][l] * dp[0][r] % MOD + 2 * dp[0][l] * dp[0][r] % MOD) % MOD;
      |  ^~
circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:36:3: error: 'dp' was not declared in this scope
   36 |   dp[0][i] = 1 - dp[0][i];
      |   ^~
circuit.cpp:40:9: error: 'dp' was not declared in this scope
   40 |  return dp[1][0];
      |         ^~