답안 #1061465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061465 2024-08-16T09:26:32 Z ewirlan 디지털 회로 (IOI22_circuit) C++17
46 / 100
708 ms 15192 KB
//
#ifndef __SIZEOF_INT128__
  #define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
    string name{""};
    time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
    duration<float, std::milli> dur;
    Timer() = default;
    Timer(string nm): name(nm) {}
    ~Timer() {
        end = high_resolution_clock::now(); dur= end - start;
        cout << "@" << name << "> " << dur.count() << " ms" << '\n';
    }
};
template <typename T = int> inline T in()
{
    static T x;
    std::cin >> x;
    return x;
}
std::string yn(bool b)
{
    if(b) return "YES\n";
    else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
    for(const auto& i : wek)out << i << ' ';
    return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
    out << '{'<<par.first<<", "<<par.second<<"}";
    return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
#include "circuit.h"
constexpr int maxn = 1e5 + 3, mod = 1e9 + 2022, pol = 1<<17;
ll mm(ll a, ll b){return (a*b)%mod;}
ll dm(ll a, ll b){return (a+b)%mod;}
ll om(ll a, ll b){return (mod+a-b)%mod;}
vector <int> syn[maxn];
int a[maxn*2], z[maxn];
int N, M;
int la(int w)
{
    a[w] = max(1, sz(syn[w]));
    for(auto i: syn[w])a[w] = mm(a[w], la(i));
    return a[w];
}
void lz(int w, ll g)
{
    if(w >= N){
        z[w-N] = g;
        return;
    }
    int ss(sz(syn[w]));
    vector <ll> p(ss+1), s(ss+1);
    p.front() = s.back() = 1;
    rep(i, 0, ss)p[i+1] = mm(a[syn[w][i]], p[i]);
    per(i, ss-1, 0)s[i] = mm(a[syn[w][i]], s[i+1]);
    rep(i, 0, ss)lz(syn[w][i], mm(g, mm(p[i], s[i+1])));
}
int tre[pol*2+3];
bool tre2[pol*2+3];
int ful[pol*2+3];
vector <bool> cc;
void init(int n, int m, vector <int> p, vector <int> c)
{
    cc.resize(m);
    rep(i, 0, m)cc[i] = c[i];
    N = n;
    M = m;
    rep(i, 1, n+m)syn[p[i]].pb(i);
    la(0);
    lz(0, 1);
    rep(i, 0, m){
        ful[pol+i] = z[i];
        tre[pol+i] = z[i]*c[i];
    }
    per(i, pol-1, 0){
        ful[i] = dm(ful[2*i], ful[2*i+1]);
        tre[i] = dm(tre[2*i], tre[2*i+1]);
    }
}
void flip(int i){
    tre[i] = om(ful[i], tre[i]);
    tre2[i] = !tre2[i];
}
void pyt(int a, int b, int p, int k, int w)
{
    // cerr << p << " - " << k << ": " << ful[w] << ' ' << tre[w] << '\n';
    if(a > k || p > b)return;
    if(a <= p && k <= b){
        // cerr << "switch " << p << ' ' << k << " (" << a << ',' << b << ')' << '\n';
        flip(w);
        return;
    }
    if(tre2[w]){
        tre2[w] = 0;
        flip(w*2);
        flip(w*2+1);
    }
    pyt(a, b, p, (p+k)/2, w*2);
    pyt(a, b, (p+k)/2+1, k, w*2+1);
    tre[w] = dm(tre[w*2], tre[w*2+1]);
}
int count_ways(int a, int b)
{
    a -= N;
    b -= N;
    pyt(a, b, 0, pol-1, 1);
    return tre[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6232 KB Output is correct
2 Correct 3 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 2 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6232 KB Output is correct
2 Correct 2 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 3 ms 6232 KB Output is correct
9 Correct 3 ms 6232 KB Output is correct
10 Correct 2 ms 6232 KB Output is correct
11 Correct 2 ms 6232 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6232 KB Output is correct
2 Correct 3 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 2 ms 6232 KB Output is correct
9 Correct 2 ms 6232 KB Output is correct
10 Correct 2 ms 6232 KB Output is correct
11 Correct 2 ms 6232 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 2 ms 6232 KB Output is correct
14 Correct 2 ms 6232 KB Output is correct
15 Correct 2 ms 6232 KB Output is correct
16 Correct 3 ms 6232 KB Output is correct
17 Correct 3 ms 6232 KB Output is correct
18 Correct 2 ms 6232 KB Output is correct
19 Correct 2 ms 6232 KB Output is correct
20 Correct 2 ms 6232 KB Output is correct
21 Correct 2 ms 6232 KB Output is correct
22 Correct 2 ms 6232 KB Output is correct
23 Correct 2 ms 6232 KB Output is correct
24 Correct 2 ms 6308 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 2 ms 6232 KB Output is correct
27 Correct 3 ms 6140 KB Output is correct
28 Correct 2 ms 6232 KB Output is correct
29 Correct 2 ms 6232 KB Output is correct
30 Correct 2 ms 6232 KB Output is correct
31 Correct 2 ms 6232 KB Output is correct
32 Correct 3 ms 6232 KB Output is correct
33 Correct 2 ms 6232 KB Output is correct
34 Correct 2 ms 6232 KB Output is correct
35 Correct 2 ms 6232 KB Output is correct
36 Correct 2 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 3 ms 6232 KB Output is correct
39 Correct 2 ms 6232 KB Output is correct
40 Correct 2 ms 6232 KB Output is correct
41 Correct 2 ms 6232 KB Output is correct
42 Correct 2 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 429 ms 8024 KB Output is correct
2 Runtime error 27 ms 15192 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 429 ms 8024 KB Output is correct
2 Runtime error 27 ms 15192 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6232 KB Output is correct
2 Correct 2 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 3 ms 6232 KB Output is correct
9 Correct 3 ms 6232 KB Output is correct
10 Correct 2 ms 6232 KB Output is correct
11 Correct 2 ms 6232 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 429 ms 8024 KB Output is correct
14 Runtime error 27 ms 15192 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6232 KB Output is correct
2 Correct 3 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 2 ms 6232 KB Output is correct
9 Correct 2 ms 6232 KB Output is correct
10 Correct 2 ms 6232 KB Output is correct
11 Correct 2 ms 6232 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 2 ms 6232 KB Output is correct
14 Correct 2 ms 6232 KB Output is correct
15 Correct 2 ms 6232 KB Output is correct
16 Correct 3 ms 6232 KB Output is correct
17 Correct 3 ms 6232 KB Output is correct
18 Correct 2 ms 6232 KB Output is correct
19 Correct 2 ms 6232 KB Output is correct
20 Correct 2 ms 6232 KB Output is correct
21 Correct 2 ms 6232 KB Output is correct
22 Correct 2 ms 6232 KB Output is correct
23 Correct 2 ms 6232 KB Output is correct
24 Correct 2 ms 6308 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 2 ms 6232 KB Output is correct
27 Correct 3 ms 6140 KB Output is correct
28 Correct 2 ms 6232 KB Output is correct
29 Correct 2 ms 6232 KB Output is correct
30 Correct 2 ms 6232 KB Output is correct
31 Correct 2 ms 6232 KB Output is correct
32 Correct 3 ms 6232 KB Output is correct
33 Correct 2 ms 6232 KB Output is correct
34 Correct 2 ms 6232 KB Output is correct
35 Correct 2 ms 6232 KB Output is correct
36 Correct 2 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 3 ms 6232 KB Output is correct
39 Correct 2 ms 6232 KB Output is correct
40 Correct 2 ms 6232 KB Output is correct
41 Correct 2 ms 6232 KB Output is correct
42 Correct 2 ms 6232 KB Output is correct
43 Correct 468 ms 6232 KB Output is correct
44 Correct 702 ms 6232 KB Output is correct
45 Correct 635 ms 6232 KB Output is correct
46 Correct 637 ms 6488 KB Output is correct
47 Correct 636 ms 6740 KB Output is correct
48 Correct 684 ms 6488 KB Output is correct
49 Correct 689 ms 6488 KB Output is correct
50 Correct 687 ms 6488 KB Output is correct
51 Correct 621 ms 6448 KB Output is correct
52 Correct 607 ms 6448 KB Output is correct
53 Correct 647 ms 7000 KB Output is correct
54 Correct 708 ms 6488 KB Output is correct
55 Correct 663 ms 6232 KB Output is correct
56 Correct 644 ms 6232 KB Output is correct
57 Correct 694 ms 6232 KB Output is correct
58 Correct 652 ms 7000 KB Output is correct
59 Correct 652 ms 7256 KB Output is correct
60 Correct 619 ms 7304 KB Output is correct
61 Correct 682 ms 6488 KB Output is correct
62 Correct 622 ms 6232 KB Output is correct
63 Correct 650 ms 6232 KB Output is correct
64 Correct 670 ms 6232 KB Output is correct
65 Correct 322 ms 6232 KB Output is correct
66 Correct 676 ms 6232 KB Output is correct
67 Correct 661 ms 6232 KB Output is correct
68 Correct 668 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6232 KB Output is correct
2 Correct 3 ms 6232 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 2 ms 6232 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 2 ms 6232 KB Output is correct
8 Correct 2 ms 6232 KB Output is correct
9 Correct 2 ms 6232 KB Output is correct
10 Correct 2 ms 6232 KB Output is correct
11 Correct 2 ms 6232 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 2 ms 6232 KB Output is correct
14 Correct 2 ms 6232 KB Output is correct
15 Correct 2 ms 6232 KB Output is correct
16 Correct 3 ms 6232 KB Output is correct
17 Correct 3 ms 6232 KB Output is correct
18 Correct 2 ms 6232 KB Output is correct
19 Correct 2 ms 6232 KB Output is correct
20 Correct 2 ms 6232 KB Output is correct
21 Correct 2 ms 6232 KB Output is correct
22 Correct 2 ms 6232 KB Output is correct
23 Correct 2 ms 6232 KB Output is correct
24 Correct 2 ms 6308 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 2 ms 6232 KB Output is correct
27 Correct 3 ms 6140 KB Output is correct
28 Correct 2 ms 6232 KB Output is correct
29 Correct 2 ms 6232 KB Output is correct
30 Correct 2 ms 6232 KB Output is correct
31 Correct 2 ms 6232 KB Output is correct
32 Correct 3 ms 6232 KB Output is correct
33 Correct 2 ms 6232 KB Output is correct
34 Correct 2 ms 6232 KB Output is correct
35 Correct 2 ms 6232 KB Output is correct
36 Correct 2 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 3 ms 6232 KB Output is correct
39 Correct 2 ms 6232 KB Output is correct
40 Correct 2 ms 6232 KB Output is correct
41 Correct 2 ms 6232 KB Output is correct
42 Correct 2 ms 6232 KB Output is correct
43 Correct 429 ms 8024 KB Output is correct
44 Runtime error 27 ms 15192 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -