Submission #790010

# Submission time Handle Problem Language Result Execution time Memory
790010 2023-07-22T09:11:48 Z Andrey Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 18412 KB
#include "circuit.h"
#include<bits/stdc++.h>
using namespace std;

long long n,m;
vector<long long> p2(300001);
vector<long long> haha[300001];
vector<long long> st(300001);
vector<long long> wow(300001);
vector<long long> no(300001);
const long long MOD = 1e9+2022;

void dfs(long long a) {
    long long sb = 0;
    if(a < n) {
        sb = 1;
    }
    for(long long v: haha[a]) {
        dfs(v);
        sb+=st[v];
    }
    st[a] = sb;
}

void dude(long long a) {
    if(!haha[a].empty()) {
        wow[haha[a][0]] = wow[a]+st[haha[a][1]];
        wow[haha[a][1]] = wow[a]+st[haha[a][0]];
        dude(haha[a][0]);
        dude(haha[a][1]);
    }
}

void init(int N, int M, vector<int> p, vector<int> a) {
    n = N;
    m = M;
    p2[0] = 1;
    for(long long i = 1; i < 300000; i++) {
        p2[i] = (p2[i-1]*2)%MOD;
    }
    for(long long i = 1; i < n+m; i++) {
        haha[p[i]].push_back(i);
    }
    dfs(0);
    dude(0);
    for(int i = 0; i < a.size(); i++) {
        no[i] = a[i];
    }
}

int count_ways(int l, int r) {
    for(long long i = l; i <= r; i++) {
        if(no[i] == 1) {
            no[i] = 0;
        }
        else {
            no[i] = 1;
        }
    }
    long long sb = 0;
    for(long long i = 0; i < m; i++) {
        sb+=p2[wow[i+n]]*no[i];
        sb%=MOD;
    }
    return sb;
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < a.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16720 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16756 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16720 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3056 ms 18412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3056 ms 18412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16756 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16720 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 16720 KB 2nd lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -