Submission #631785

# Submission time Handle Problem Language Result Execution time Memory
631785 2022-08-18T17:50:14 Z blue Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 9408 KB
#include "circuit.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll mod = 1'000'002'022;

ll ad(ll a, ll b)
{
	return (a+b)%mod;
}

ll mul(ll a, ll b)
{
	return (a*b)%mod;
}

const int mx = 200'000;

vll pow2(1 + mx);

int N, M;
vi A;

vi depth(1 + mx, 1);
vi children[1 + mx];

void dfs(int u)
{
	for(int v : children[u])
	{
		depth[v] = depth[u] + 1;
		dfs(v);
	}
}

void init(int N_, int M_, vi P_, vi A_)
{
	N = N_;
	M = M_;

	A = vi(N);
	for(int z : A_)
		A.push_back(z);

	pow2[0] = 1;
	for(int e = 1; e <= mx; e++)
		pow2[e] = mul(pow2[e-1], 2);

	for(int i = 1; i < N+M; i++)
		children[P_[i]].push_back(i);

	// cerr << "hello\n";

	dfs(0);
	// cerr << "done\n";
}

int count_ways(int L, int R)
{
	for(int i = L; i <= R; i++)
		A[i] = !A[i];

	// for(int i = N; i < N+M; i++)
	// 	cerr << A[i] << ' ';
	// cerr << '\n';

	ll res = 0;
	for(int i = N; i < N+M; i++)
	{
		// cerr << i << " : " << depth[i] << '\n';
		res = ad(res, mul(pow2[N+M - depth[i]], A[i]));
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7248 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7360 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7248 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 9408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 9408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7360 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7248 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7248 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -