Submission #643488

# Submission time Handle Problem Language Result Execution time Memory
643488 2022-09-22T07:06:46 Z Vanilla Digital Circuit (IOI22_circuit) C++17
0 / 100
15 ms 1964 KB
#include <bits/stdc++.h>
#include "circuit.h"
typedef long long int64;
using namespace std;
const int64 mod = 1000002022;
const int maxn = 2e3 + 2;
// vector <int> ad [maxn];
int64 dp[maxn][2];
int64 lazy[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] = !lazy[x];
    swap(dp[x][0], dp[x][1]);
    return;
  }
  if (l > ir || r < il) return;
  push(x, nl, nr);
  int mid = (l + r) / 2;
  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 1 ms 208 KB Output is correct
2 Incorrect 0 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 Runtime error 15 ms 1964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 1964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 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 -