답안 #1061462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061462 2024-08-16T09:20:15 Z ewirlan 디지털 회로 (IOI22_circuit) C++17
46 / 100
3000 ms 8032 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];
bool tre2[pol*2];
int ful[pol*2];
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 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';
        tre2[w] = !tre2[w];
        tre[w] = om(ful[w], tre[w]);
        return;
    }
    if(tre2[w]){
        tre2[w] = 0;
        tre2[w*2] = tre2[w*2+1] = 1;
        tre[w*2] = om(ful[w*2], tre[w*2]);
        tre[w*2+1] = om(ful[w*2+1], tre[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)
{
    // pyt(a-N, b-N, 0, pol-1, 1);
    a -= N;
    b -= N;
    rep(i, a, b+1)cc[i] = !cc[i];
    ll o(0);
    rep(i, 0, M)if(cc[i])o = dm(o, z[i]);
    return o;
}
# 결과 실행 시간 메모리 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 6128 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 6056 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 3 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
# 결과 실행 시간 메모리 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 6128 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 6056 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 3 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 2 ms 6232 KB Output is correct
17 Correct 2 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 6232 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 3 ms 6232 KB Output is correct
27 Correct 2 ms 6232 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 2 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 3 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 2 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 6132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3041 ms 8032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3041 ms 8032 KB Time limit exceeded
2 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 6056 KB Output is correct
4 Correct 2 ms 6232 KB Output is correct
5 Correct 3 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 Execution timed out 3041 ms 8032 KB Time limit exceeded
14 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 6128 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 6056 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 3 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 2 ms 6232 KB Output is correct
17 Correct 2 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 6232 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 3 ms 6232 KB Output is correct
27 Correct 2 ms 6232 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 2 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 3 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 2 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 6132 KB Output is correct
43 Correct 983 ms 6232 KB Output is correct
44 Correct 1286 ms 6232 KB Output is correct
45 Correct 1399 ms 6232 KB Output is correct
46 Correct 1533 ms 6488 KB Output is correct
47 Correct 1998 ms 6488 KB Output is correct
48 Correct 2027 ms 6488 KB Output is correct
49 Correct 2016 ms 6488 KB Output is correct
50 Correct 2267 ms 6488 KB Output is correct
51 Correct 2293 ms 6452 KB Output is correct
52 Correct 2009 ms 6448 KB Output is correct
53 Correct 580 ms 7000 KB Output is correct
54 Correct 2055 ms 6488 KB Output is correct
55 Correct 2005 ms 6232 KB Output is correct
56 Correct 2020 ms 6232 KB Output is correct
57 Correct 2001 ms 6232 KB Output is correct
58 Correct 1996 ms 7000 KB Output is correct
59 Correct 2001 ms 7256 KB Output is correct
60 Correct 2323 ms 7256 KB Output is correct
61 Correct 1253 ms 6488 KB Output is correct
62 Correct 1573 ms 6232 KB Output is correct
63 Correct 1662 ms 6232 KB Output is correct
64 Correct 2015 ms 6232 KB Output is correct
65 Correct 597 ms 6232 KB Output is correct
66 Correct 1762 ms 6232 KB Output is correct
67 Correct 1744 ms 6232 KB Output is correct
68 Correct 2055 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 6128 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 6056 KB Output is correct
12 Correct 2 ms 6232 KB Output is correct
13 Correct 3 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 2 ms 6232 KB Output is correct
17 Correct 2 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 6232 KB Output is correct
25 Correct 2 ms 6232 KB Output is correct
26 Correct 3 ms 6232 KB Output is correct
27 Correct 2 ms 6232 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 2 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 3 ms 6232 KB Output is correct
37 Correct 2 ms 6232 KB Output is correct
38 Correct 2 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 6132 KB Output is correct
43 Execution timed out 3041 ms 8032 KB Time limit exceeded
44 Halted 0 ms 0 KB -