답안 #785874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785874 2023-07-17T17:30:15 Z Andrey 디지털 회로 (IOI22_circuit) C++17
4 / 100
1850 ms 2097152 KB
#include "circuit.h"
#include<bits/stdc++.h>
using namespace std;

vector<long long> dp(300001);
vector<long long> bruh(300001);
vector<long long> br(300001);
vector<long long> f(300001);
long long p2[300001];
long long n,m;
const long long MOD = 1e9+2022;

void upd(long long l, long long r, long long x, long long nl, long long nr) {
    if(l == nl && r == nr) {
        f[x]++;
        return;
    }
    long long m = (nl+nr)/2;
    if(r <= m) {
        upd(l,r,x*2+1,nl,m);
    }
    else if(l > m) {
        upd(l,r,x*2+2,m+1,nr);
    }
    else {
        upd(l,m,x*2+1,nl,m);
        upd(m+1,r,x*2+2,m+1,nr);
    }
    long long a = dp[x*2+1],b = dp[x*2+2];
    if(f[x*2+1]%2) {
        a = (p2[br[x*2+1]]-a+MOD)%MOD;
    }
    if(f[x*2+2]%2) {
        b = (p2[br[x*2+2]]-b+MOD)%MOD;
    }
    dp[x] = (p2[br[x*2+1]]*(a+b))%MOD;
}

void build(long long x) {
    if(x >= n) {
        dp[x] = bruh[x];
        br[x] = 0;
        return;
    }
    build(x*2+1);
    build(x*2+2);
    dp[x] = (p2[br[x*2+1]]*(dp[x*2+1]+dp[x*2+2]))%MOD;
    br[x] = br[x*2+1]*2+1;
}

void init(int N, int M, vector<int> p, vector<int> a) {
    p2[0] = 1;
    for(int i = 1; i < 300001; i++) {
        p2[i] = (p2[i-1]*2)%MOD;
    }
    n = N;
    m = M;
    for(int i = n; i < n+a.size(); i++) {
        bruh[i] = a[i-n];
    }
    build(0);
}

int count_ways(int l, int r) {
    upd(l-n,r-n,0,0,n);
    long long a = dp[0];
    if(f[0]%2) {
        a = p2[br[0]]-dp[0];
    }
    return a;
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   58 |     for(int i = n; i < n+a.size(); i++) {
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 12048 KB Output is correct
3 Runtime error 1850 ms 2097152 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 11984 KB Output is correct
3 Correct 6 ms 11984 KB Output is correct
4 Correct 6 ms 11984 KB Output is correct
5 Correct 6 ms 11984 KB Output is correct
6 Incorrect 6 ms 11984 KB 1st lines differ - on the 1st token, expected: '706880838', found: '530378676'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 12048 KB Output is correct
3 Runtime error 1850 ms 2097152 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 470 ms 12752 KB Output is correct
2 Correct 753 ms 13572 KB Output is correct
3 Correct 740 ms 13520 KB Output is correct
4 Correct 680 ms 13540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 470 ms 12752 KB Output is correct
2 Correct 753 ms 13572 KB Output is correct
3 Correct 740 ms 13520 KB Output is correct
4 Correct 680 ms 13540 KB Output is correct
5 Correct 617 ms 12812 KB Output is correct
6 Correct 840 ms 13548 KB Output is correct
7 Correct 770 ms 13520 KB Output is correct
8 Incorrect 654 ms 13516 KB 261st lines differ - on the 1st token, expected: '987306502', found: '-12695520'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 11984 KB Output is correct
3 Correct 6 ms 11984 KB Output is correct
4 Correct 6 ms 11984 KB Output is correct
5 Correct 6 ms 11984 KB Output is correct
6 Incorrect 6 ms 11984 KB 1st lines differ - on the 1st token, expected: '706880838', found: '530378676'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 12048 KB Output is correct
3 Runtime error 1850 ms 2097152 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11984 KB Output is correct
2 Correct 6 ms 12048 KB Output is correct
3 Runtime error 1850 ms 2097152 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -