답안 #1061456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061456 2024-08-16T09:16:42 Z ewirlan 디지털 회로 (IOI22_circuit) C++17
0 / 100
480 ms 14936 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];
void init(int n, int m, vector <int> p, vector <int> c)
{
    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);
    return tre[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6232 KB Output is correct
2 Correct 2 ms 6232 KB Output is correct
3 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '481', found: '491'
4 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 6060 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 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '281705356', found: '51405574'
9 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 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '481', found: '491'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 480 ms 8024 KB Output is correct
2 Runtime error 24 ms 14936 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 480 ms 8024 KB Output is correct
2 Runtime error 24 ms 14936 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 6060 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 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '281705356', found: '51405574'
9 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 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '481', found: '491'
4 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 Incorrect 2 ms 6232 KB 5th lines differ - on the 1st token, expected: '481', found: '491'
4 Halted 0 ms 0 KB -