Submission #643492

# Submission time Handle Problem Language Result Execution time Memory
643492 2022-09-22T07:14:01 Z Vanilla Digital Circuit (IOI22_circuit) C++17
0 / 100
630 ms 2000 KB
#include <bits/stdc++.h>
#include "circuit.h"
typedef long long int64;
using namespace std;
const int64 mod = 1000002022;
const int maxn = 2e5 + 2;
// vector <int> ad [maxn];
int64 dp[4 * maxn][2];
int64 lazy[4 * maxn];
int n,m;

void init(int N, int M, vector<int> P, vector<int> A) {
  n = N, m = M;
  for (int i = 0; i < M; i++){
    dp[N+i][A[i]] = 1;
  }
}

void push (int x, int nl, int nr) {
  if (!lazy[x]) return;
  swap(dp[nl][0], dp[nl][1]);
  swap(dp[nr][0], dp[nr][1]);
  lazy[nl] = !lazy[nl];
  lazy[nr] = !lazy[nr];
  lazy[x] = 0;
}

void upd (int x, int l, int r, int il, int ir) {
  int nl = x * 2 + 1, nr = x * 2 + 2;
  if (il <= l && r <= ir) {
    lazy[x] = 1;
    swap(dp[x][0], dp[x][1]);
    return;
  }
  if (l > ir || r < il) return;
  int mid = (l + r) / 2;
  push(x, nl, nr);
  upd(nl, l, mid, il, ir); upd(nr, mid + 1, r, il, ir);
  dp[x][0] = ((dp[nl][0] * dp[nr][0] * 2 % mod) + (dp[nl][0] * dp[nr][1] % mod) + (dp[nl][1] * dp[nr][0] % mod)) % mod;
  dp[x][1] = ((dp[nl][1] * dp[nr][1] * 2 % mod) + (dp[nl][0] * dp[nr][1] % mod) + (dp[nl][1] * dp[nr][0] % mod)) % mod;
}

int count_ways(int L, int R) {
  // for (int i = L; i <= R; i++){
  //   swap(dp[i][0], dp[i][1]);
  // }
  upd(0, n, n + m - 1, L, R);
  return dp[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 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 0 ms 208 KB Output is correct
2 Incorrect 1 ms 208 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 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 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 Incorrect 630 ms 2000 KB 1st lines differ - on the 1st token, expected: '431985922', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 630 ms 2000 KB 1st lines differ - on the 1st token, expected: '431985922', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 1 ms 208 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 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 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 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -