답안 #632979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632979 2022-08-21T11:01:28 Z tutis 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 4944 KB
#include "circuit.h"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000002022;
vector<pair<ll, ll>>a;

vector<int>P;
vector<int>A;
vector<vector<int>>c;
int N, M;
void calc(int i)
{
    int d = c[i].size();
    vector<ll> k(d + 2, 0ll);
    k[0] = 1;
    for (int j : c[i])
    {
        int v0 = a[j].first;
        int v1 = a[j].second;
        for (int t = d; t >= 0; t--)
        {
            k[t + 1] += v1 * k[t];
            k[t + 1] %= mod;
            k[t] = v0 * k[t];
            k[t] %= mod;
        }
    }
    a[i] = {0ll, 0ll};
    for (int t = 0; t <= d; t++)
    {
        a[i].second += k[t] * t;
        a[i].second %= mod;
        a[i].first += k[t] * (d - t);
        a[i].first %= mod;
    }
}
void init(int N_, int M_, vector<int> P_, vector<int> A_) {
    P = P_;
    A = A_;
    N = N_;
    M = M_;
    a = vector<pair<ll, ll>>(N + M);
    c = vector<vector<int>>(N + M);
    for (int i = 1; i < N + M; i++)
        c[P[i]].push_back(i);
    for (int i = N + M - 1; i >= N; i--)
    {
        if (A[i - N] == 1)
            a[i] = {0, 1};
        else
            a[i] = {1, 0};
    }
    for (int i = N - 1; i >= 0; i--)
        calc(i);
}

int count_ways(int L, int R) {
    for (int i = L; i <= R; i++)
        swap(a[i].first, a[i].second);
    for (int i = N - 1; i >= 0; i--)
        calc(i);
    return (int)a[0].second;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 17 ms 364 KB Output is correct
4 Correct 19 ms 336 KB Output is correct
5 Correct 18 ms 336 KB Output is correct
6 Correct 18 ms 336 KB Output is correct
7 Correct 18 ms 336 KB Output is correct
8 Correct 18 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 17 ms 364 KB Output is correct
4 Correct 19 ms 336 KB Output is correct
5 Correct 18 ms 336 KB Output is correct
6 Correct 18 ms 336 KB Output is correct
7 Correct 18 ms 336 KB Output is correct
8 Correct 18 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 19 ms 336 KB Output is correct
30 Correct 18 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 20 ms 336 KB Output is correct
38 Correct 18 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 3030 ms 4944 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 17 ms 364 KB Output is correct
4 Correct 19 ms 336 KB Output is correct
5 Correct 18 ms 336 KB Output is correct
6 Correct 18 ms 336 KB Output is correct
7 Correct 18 ms 336 KB Output is correct
8 Correct 18 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 19 ms 336 KB Output is correct
30 Correct 18 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 20 ms 336 KB Output is correct
38 Correct 18 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Execution timed out 3061 ms 720 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 17 ms 364 KB Output is correct
4 Correct 19 ms 336 KB Output is correct
5 Correct 18 ms 336 KB Output is correct
6 Correct 18 ms 336 KB Output is correct
7 Correct 18 ms 336 KB Output is correct
8 Correct 18 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 19 ms 336 KB Output is correct
30 Correct 18 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 20 ms 336 KB Output is correct
38 Correct 18 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Execution timed out 3030 ms 4944 KB Time limit exceeded
44 Halted 0 ms 0 KB -