답안 #720388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720388 2023-04-08T06:16:07 Z vjudge1 디지털 회로 (IOI22_circuit) C++17
18 / 100
42 ms 30804 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define MAX 300001
#define INF LLONG_MAX
#define MOD 1000002022
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
    for(int i=0;i<b;i++){\
        cin >> a[i];\
    }\
}
#define inputvec(a,b){\
    for(int i=0;i<b;i++){\
        ll num;\
        cin >> num;\
        a.pb(num);\
    }\
}
#define outputar(a,b){\
    for(int i=0;i<b;i++){\
        cout << a[i] << " ";\
    }\
    cout << "\n";\
}
#define outputvec(a){\
    for(auto x:a){\
        cout << x << " ";\
    }\
    cout << "\n";\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
ll n,q,t=1,m,n2,m2,k,cnt=0,x,y,z,x2,y2,z2,res1=0,cnt1,cnt2,cnt3;
ll c[501][501];
ll fact[MAX];
ll inv_fact[MAX];
//char c;
string str[MAX];
string s1,s2;
vector<tuple<ll,ll,ll>> v;
vector<pll> v1,v2,v3,v4;
const int mod = 998244353;
vector<int> a,b;
vector<vector<ll>> g;
ll dp[2005][2005];
ll dp3[2005][2];
void dfs(ll v){
    ll sz=g[v].size();
    if(!sz){
        if(b[v-n]==0){
            dp3[v][0]=1;
            dp3[v][1]=0;
        }
        else{
            dp3[v][0]=0;
            dp3[v][1]=1;
        }
        return;
    }
    for(int i=0;i<=sz;i++){
        dp[v][i]=0;
    }
    dp3[v][0]=0;
    dp3[v][1]=0;
    dp[v][0]=1;
    vector<ll> arr(sz+1,0);
    for(auto x:g[v]){
        dfs(x);
        for(int i=0;i<=sz;i++){
            arr[i]+=(dp[v][i]*dp3[x][0])%MOD;
            arr[i]%=MOD;
        }
        for(int i=1;i<=sz;i++){
            arr[i]+=(dp[v][i-1]*dp3[x][1])%MOD;
            arr[i]%=MOD;
        }
        for(int i=0;i<=sz;i++){
            dp[v][i]=arr[i];
            arr[i]=0;
        }
    }
    for(ll i=0;i<=sz;i++){
        dp3[v][1]+=(i*dp[v][i])%MOD;
        dp3[v][0]+=((sz-i)*dp[v][i])%MOD;
        dp3[v][1]%=MOD;
        dp3[v][0]%=MOD;
    }
}
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
    n=N;
    m=M;
    a=P;
    b=A;
    g.resize(N+M);
    for(int i=1;i<N+M;i++){
        g[P[i]].pb(i);
    }
}
int count_ways(int L, int R) {
  for(int i=L-n;i<=R-n;i++){
      b[i]=(1-b[i]);
  }
  dfs(0);
  return (int)dp3[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 5 ms 9680 KB Output is correct
3 Correct 33 ms 9680 KB Output is correct
4 Correct 42 ms 9680 KB Output is correct
5 Correct 33 ms 9680 KB Output is correct
6 Correct 33 ms 9680 KB Output is correct
7 Correct 35 ms 9680 KB Output is correct
8 Correct 34 ms 9680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 6 ms 10732 KB Output is correct
3 Correct 9 ms 11728 KB Output is correct
4 Correct 6 ms 11728 KB Output is correct
5 Correct 7 ms 11852 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 8 ms 13888 KB Output is correct
8 Correct 8 ms 13872 KB Output is correct
9 Correct 8 ms 13776 KB Output is correct
10 Correct 8 ms 14032 KB Output is correct
11 Correct 8 ms 14036 KB Output is correct
12 Correct 9 ms 13136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 5 ms 9680 KB Output is correct
3 Correct 33 ms 9680 KB Output is correct
4 Correct 42 ms 9680 KB Output is correct
5 Correct 33 ms 9680 KB Output is correct
6 Correct 33 ms 9680 KB Output is correct
7 Correct 35 ms 9680 KB Output is correct
8 Correct 34 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 6 ms 10732 KB Output is correct
11 Correct 9 ms 11728 KB Output is correct
12 Correct 6 ms 11728 KB Output is correct
13 Correct 7 ms 11852 KB Output is correct
14 Correct 7 ms 12624 KB Output is correct
15 Correct 8 ms 13888 KB Output is correct
16 Correct 8 ms 13872 KB Output is correct
17 Correct 8 ms 13776 KB Output is correct
18 Correct 8 ms 14032 KB Output is correct
19 Correct 8 ms 14036 KB Output is correct
20 Correct 9 ms 13136 KB Output is correct
21 Correct 8 ms 12676 KB Output is correct
22 Correct 8 ms 13008 KB Output is correct
23 Correct 7 ms 12368 KB Output is correct
24 Correct 8 ms 13904 KB Output is correct
25 Correct 8 ms 13776 KB Output is correct
26 Correct 11 ms 13940 KB Output is correct
27 Correct 10 ms 13784 KB Output is correct
28 Correct 8 ms 13776 KB Output is correct
29 Correct 37 ms 9776 KB Output is correct
30 Correct 41 ms 9776 KB Output is correct
31 Correct 8 ms 13972 KB Output is correct
32 Correct 9 ms 13776 KB Output is correct
33 Correct 8 ms 11728 KB Output is correct
34 Correct 7 ms 10704 KB Output is correct
35 Correct 12 ms 9680 KB Output is correct
36 Correct 9 ms 13952 KB Output is correct
37 Correct 39 ms 14032 KB Output is correct
38 Correct 41 ms 14032 KB Output is correct
39 Correct 8 ms 12624 KB Output is correct
40 Correct 7 ms 11856 KB Output is correct
41 Correct 7 ms 11216 KB Output is correct
42 Correct 7 ms 9936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 26328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 26328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 6 ms 10732 KB Output is correct
3 Correct 9 ms 11728 KB Output is correct
4 Correct 6 ms 11728 KB Output is correct
5 Correct 7 ms 11852 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 8 ms 13888 KB Output is correct
8 Correct 8 ms 13872 KB Output is correct
9 Correct 8 ms 13776 KB Output is correct
10 Correct 8 ms 14032 KB Output is correct
11 Correct 8 ms 14036 KB Output is correct
12 Correct 9 ms 13136 KB Output is correct
13 Runtime error 28 ms 26328 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 5 ms 9680 KB Output is correct
3 Correct 33 ms 9680 KB Output is correct
4 Correct 42 ms 9680 KB Output is correct
5 Correct 33 ms 9680 KB Output is correct
6 Correct 33 ms 9680 KB Output is correct
7 Correct 35 ms 9680 KB Output is correct
8 Correct 34 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 6 ms 10732 KB Output is correct
11 Correct 9 ms 11728 KB Output is correct
12 Correct 6 ms 11728 KB Output is correct
13 Correct 7 ms 11852 KB Output is correct
14 Correct 7 ms 12624 KB Output is correct
15 Correct 8 ms 13888 KB Output is correct
16 Correct 8 ms 13872 KB Output is correct
17 Correct 8 ms 13776 KB Output is correct
18 Correct 8 ms 14032 KB Output is correct
19 Correct 8 ms 14036 KB Output is correct
20 Correct 9 ms 13136 KB Output is correct
21 Correct 8 ms 12676 KB Output is correct
22 Correct 8 ms 13008 KB Output is correct
23 Correct 7 ms 12368 KB Output is correct
24 Correct 8 ms 13904 KB Output is correct
25 Correct 8 ms 13776 KB Output is correct
26 Correct 11 ms 13940 KB Output is correct
27 Correct 10 ms 13784 KB Output is correct
28 Correct 8 ms 13776 KB Output is correct
29 Correct 37 ms 9776 KB Output is correct
30 Correct 41 ms 9776 KB Output is correct
31 Correct 8 ms 13972 KB Output is correct
32 Correct 9 ms 13776 KB Output is correct
33 Correct 8 ms 11728 KB Output is correct
34 Correct 7 ms 10704 KB Output is correct
35 Correct 12 ms 9680 KB Output is correct
36 Correct 9 ms 13952 KB Output is correct
37 Correct 39 ms 14032 KB Output is correct
38 Correct 41 ms 14032 KB Output is correct
39 Correct 8 ms 12624 KB Output is correct
40 Correct 7 ms 11856 KB Output is correct
41 Correct 7 ms 11216 KB Output is correct
42 Correct 7 ms 9936 KB Output is correct
43 Runtime error 30 ms 30804 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 5 ms 9680 KB Output is correct
3 Correct 33 ms 9680 KB Output is correct
4 Correct 42 ms 9680 KB Output is correct
5 Correct 33 ms 9680 KB Output is correct
6 Correct 33 ms 9680 KB Output is correct
7 Correct 35 ms 9680 KB Output is correct
8 Correct 34 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 6 ms 10732 KB Output is correct
11 Correct 9 ms 11728 KB Output is correct
12 Correct 6 ms 11728 KB Output is correct
13 Correct 7 ms 11852 KB Output is correct
14 Correct 7 ms 12624 KB Output is correct
15 Correct 8 ms 13888 KB Output is correct
16 Correct 8 ms 13872 KB Output is correct
17 Correct 8 ms 13776 KB Output is correct
18 Correct 8 ms 14032 KB Output is correct
19 Correct 8 ms 14036 KB Output is correct
20 Correct 9 ms 13136 KB Output is correct
21 Correct 8 ms 12676 KB Output is correct
22 Correct 8 ms 13008 KB Output is correct
23 Correct 7 ms 12368 KB Output is correct
24 Correct 8 ms 13904 KB Output is correct
25 Correct 8 ms 13776 KB Output is correct
26 Correct 11 ms 13940 KB Output is correct
27 Correct 10 ms 13784 KB Output is correct
28 Correct 8 ms 13776 KB Output is correct
29 Correct 37 ms 9776 KB Output is correct
30 Correct 41 ms 9776 KB Output is correct
31 Correct 8 ms 13972 KB Output is correct
32 Correct 9 ms 13776 KB Output is correct
33 Correct 8 ms 11728 KB Output is correct
34 Correct 7 ms 10704 KB Output is correct
35 Correct 12 ms 9680 KB Output is correct
36 Correct 9 ms 13952 KB Output is correct
37 Correct 39 ms 14032 KB Output is correct
38 Correct 41 ms 14032 KB Output is correct
39 Correct 8 ms 12624 KB Output is correct
40 Correct 7 ms 11856 KB Output is correct
41 Correct 7 ms 11216 KB Output is correct
42 Correct 7 ms 9936 KB Output is correct
43 Runtime error 28 ms 26328 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -