답안 #1058451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058451 2024-08-14T10:03:37 Z mychecksedad 디지털 회로 (IOI22_circuit) C++17
0 / 100
308 ms 19236 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define en cout << '\n'
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vi vector<int>
#define ll long long int
#define ff first
#define ss second
#define MOD 1000002022
const int N = 500000+10;

int n, m;
vector<int> g[N];
array<ll, 4> T[N];
vi val;
int lazy[N];
int F;
array<ll, 4> comb(array<ll, 4> x, array<ll, 4> y){
  array<ll, 4> z;
  z[0] = x[0] * y[0] % MOD;
  z[1] = (x[0] * y[1] + x[1] * y[0] + x[1] * y[1]) % MOD;
  z[2] = x[2] * y[2] % MOD;
  z[3] = (x[2] * y[3] + x[3] * y[2] + x[3] * y[3]) % MOD;
  return z;
}
void build(int l, int r, int k){
  lazy[k] = 0;
  if(l == r){
    T[k] = {
      val[l],
      1-val[l],
      1-val[l],
      val[l]
    };
    return;
  }
  int m = l+r>>1;
  build(l, m, k<<1);
  build(m+1, r, k<<1|1);
  T[k] = comb(T[k<<1], T[k<<1|1]);
}
int get(){
  return T[1][0];
}
void push(int k){
  if(lazy[k]){
    lazy[k<<1] ^= lazy[k];
    lazy[k<<1|1] ^= lazy[k];
    swap(T[k<<1][0], T[k<<1][2]);
    swap(T[k<<1][1], T[k<<1][3]);
    swap(T[k<<1|1][0], T[k<<1|1][2]);
    swap(T[k<<1|1][1], T[k<<1|1][3]);
    lazy[k] = 0;
  }
}
void upd(int l, int r, int ql, int qr, int k){
  if(ql > r || l > qr) return;
  if(ql <= l && r <= qr){
    swap(T[k][0], T[k][2]);
    swap(T[k][1], T[k][3]);
    lazy[k] ^= 1;
    return;
  }
  push(k);
  int m = l+r>>1;
  upd(l, m, ql, qr, k<<1);
  upd(m+1, r, ql, qr, k<<1|1);
  T[k] = comb(T[k<<1], T[k<<1|1]);
}
void init(int nn, int mm, std::vector<int> P, std::vector<int> A) { n=nn, m=mm;
  for(int i = 1; i < n + m; ++i) g[P[i]].pb(i);
  val = A;
  build(0, m - 1, 1);
}

int count_ways(int L, int R) {
  upd(0, m - 1, L, R, 1);
  return get();
}

Compilation message

circuit.cpp: In function 'void build(int, int, int)':
circuit.cpp:40:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |   int m = l+r>>1;
      |           ~^~
circuit.cpp: In function 'void upd(int, int, int, int, int)':
circuit.cpp:68:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   68 |   int m = l+r>>1;
      |           ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 308 ms 19236 KB 1st lines differ - on the 1st token, expected: '431985922', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 308 ms 19236 KB 1st lines differ - on the 1st token, expected: '431985922', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 15192 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -