Submission #825415

# Submission time Handle Problem Language Result Execution time Memory
825415 2023-08-14T19:46:40 Z pere_gil Digital Circuit (IOI22_circuit) C++17
7 / 100
3000 ms 2097152 KB
#include "circuit.h"
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define ii pair<ll,ll>

const ll mod=1000002022;
const int mxn=2e5+5;
int n,m;
vector<int> p,a;
ll res[mxn][2];
int adj[mxn][2];

void init(int N, int M, vector<int> P, vector<int> A) {
  n=N,m=M;
  p=P;
  for(int i=0;i<n;i++) a.emplace_back(0);
  for(int i=0;i<m;i++) a.emplace_back(A[i]);

  memset(adj,-1,sizeof adj);
  
  for(int i=1;i<n+m;i++)
    adj[p[i]][adj[p[i]][0]!=-1]=i;
}

ii dfs(int u){
  if(u>=n) return {!a[u],a[u]};
  ii l=dfs(adj[u][0]),r=dfs(adj[u][1]);
  ll left=((l.first*r.second)%mod+(l.second*r.first)%mod+(2*l.first*r.first)%mod)%mod;
  ll right=((l.first*r.second)%mod+(l.second*r.first)%mod+(2*l.second*r.second)%mod)%mod;
  return {left,right};
}

int count_ways(int l, int r) {
  for(int i=l;i<=r;i++) a[i]=1-a[i];

  return dfs(0).second;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1872 KB Output is correct
2 Runtime error 1004 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1872 KB Output is correct
3 Correct 1 ms 1872 KB Output is correct
4 Correct 1 ms 1872 KB Output is correct
5 Correct 1 ms 1872 KB Output is correct
6 Correct 1 ms 1872 KB Output is correct
7 Correct 1 ms 1872 KB Output is correct
8 Correct 1 ms 1872 KB Output is correct
9 Correct 1 ms 1872 KB Output is correct
10 Correct 1 ms 1872 KB Output is correct
11 Correct 1 ms 1872 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1872 KB Output is correct
2 Runtime error 1004 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 3244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 3244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1872 KB Output is correct
3 Correct 1 ms 1872 KB Output is correct
4 Correct 1 ms 1872 KB Output is correct
5 Correct 1 ms 1872 KB Output is correct
6 Correct 1 ms 1872 KB Output is correct
7 Correct 1 ms 1872 KB Output is correct
8 Correct 1 ms 1872 KB Output is correct
9 Correct 1 ms 1872 KB Output is correct
10 Correct 1 ms 1872 KB Output is correct
11 Correct 1 ms 1872 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
13 Execution timed out 3081 ms 3244 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1872 KB Output is correct
2 Runtime error 1004 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1872 KB Output is correct
2 Runtime error 1004 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -