Submission #1059874

# Submission time Handle Problem Language Result Execution time Memory
1059874 2024-08-15T08:50:25 Z parsadox2 Digital Circuit (IOI22_circuit) C++17
2 / 100
3000 ms 7512 KB
#include <bits/stdc++.h>
#include "circuit.h"

using namespace std;

const int N = 2e5 + 10 , mod = 1000002022;
int sbt[N] , n , m , zarib[N];
vector <int> p , a , adj[N];

void Find_sbt(int v)
{
	sbt[v] = adj[v].size();
	if(sbt[v] == 0)
		sbt[v] = 1;
	for(auto u : adj[v])
	{
		Find_sbt(u);
		sbt[v] = 1LL * sbt[v] * sbt[u] % mod;
	}
	//cout << v << " : " << sbt[v] << endl;
}

void Add(int v , int val)
{
	if(v >= n)
	{
		zarib[v - n] = 1LL * zarib[v - n] * val % mod;
		return;
	}
	for(auto u : adj[v])
		Add(u , val);
}

void Dfs(int v)
{
	for(auto u : adj[v])  for(auto w : adj[v])  if(u != w)
		Add(w , sbt[u]);
}

void init(int nn , int mm , vector <int> pp , vector <int> aa)
{
	n = nn;
	m = mm;
	p = pp;
	a = aa;
	for(int i = 0 ; i < m ; i++)
		zarib[i] = 1;
	for(int i = 1 ; i < n + m ; i++)
		adj[p[i]].push_back(i);
	Find_sbt(0);
	Dfs(0);
	/*for(int i = 0 ; i < m ; i++)
		cout << a[i] << " " << zarib[i] << endl;
		*/
}

int count_ways(int l , int r)
{
	for(int i = l ; i <= r ; i++)
		a[i - n] ^= 1;
	int res = 0;
	for(int i = 0 ; i < m ; i++)  if(a[i] == 1)
	{
		res = (res + zarib[i]) % mod;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Correct 4 ms 4952 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 4 ms 5180 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '52130940', found: '678497364'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Correct 4 ms 4952 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 4 ms 5180 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '52130940', found: '678497364'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3094 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3094 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '52130940', found: '678497364'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Correct 4 ms 4952 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 4 ms 5180 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '52130940', found: '678497364'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Correct 4 ms 4952 KB Output is correct
5 Correct 4 ms 4952 KB Output is correct
6 Correct 4 ms 5180 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '52130940', found: '678497364'
11 Halted 0 ms 0 KB -