Submission #790012

# Submission time Handle Problem Language Result Execution time Memory
790012 2023-07-22T09:13:46 Z Andrey Digital Circuit (IOI22_circuit) C++17
7 / 100
3000 ms 18540 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-n; i <= r-n; 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 Correct 9 ms 16720 KB Output is correct
2 Execution timed out 3061 ms 16720 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 16648 KB Output is correct
2 Correct 8 ms 16764 KB Output is correct
3 Correct 8 ms 16776 KB Output is correct
4 Correct 9 ms 16720 KB Output is correct
5 Correct 8 ms 16720 KB Output is correct
6 Correct 9 ms 16720 KB Output is correct
7 Correct 9 ms 16720 KB Output is correct
8 Correct 9 ms 16720 KB Output is correct
9 Correct 9 ms 16720 KB Output is correct
10 Correct 8 ms 16848 KB Output is correct
11 Correct 9 ms 16760 KB Output is correct
12 Correct 9 ms 16788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 16720 KB Output is correct
2 Execution timed out 3061 ms 16720 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3093 ms 18540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3093 ms 18540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 16648 KB Output is correct
2 Correct 8 ms 16764 KB Output is correct
3 Correct 8 ms 16776 KB Output is correct
4 Correct 9 ms 16720 KB Output is correct
5 Correct 8 ms 16720 KB Output is correct
6 Correct 9 ms 16720 KB Output is correct
7 Correct 9 ms 16720 KB Output is correct
8 Correct 9 ms 16720 KB Output is correct
9 Correct 9 ms 16720 KB Output is correct
10 Correct 8 ms 16848 KB Output is correct
11 Correct 9 ms 16760 KB Output is correct
12 Correct 9 ms 16788 KB Output is correct
13 Execution timed out 3093 ms 18540 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 16720 KB Output is correct
2 Execution timed out 3061 ms 16720 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 16720 KB Output is correct
2 Execution timed out 3061 ms 16720 KB Time limit exceeded
3 Halted 0 ms 0 KB -