QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#444336#8648. Towergreen_gold_dog#0 30ms18888kbC++235.8kb2024-06-15 18:24:302024-06-15 18:24:31

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 18:24:31]
  • 评测
  • 测评结果:0
  • 用时:30ms
  • 内存:18888kb
  • [2024-06-15 18:24:30]
  • 提交

answer

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;

constexpr ll INF64 = 2'000'000'000'000'000'000, MOD = 1'000'000'007;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;

random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());

template<typename T>
bool assign_max(T& a, T b) {
        if (b > a) {
                a = b;
                return true;
        }
        return false;
}

template<typename T>
bool assign_min(T& a, T b) {
        if (b < a) {
                a = b;
                return true;
        }
        return false;
}

template<typename T>
T square(T a) {
        return a * a;
}

template<>
struct std::hash<pair<ll, ll>> {
        ll operator() (pair<ll, ll> p) const {
                return ((__int128)p.first * MOD + p.second) % INF64;
        }
};

struct Node {
        ll tree, ms, madd, maddp;
        ll l, r;
        Node *nl = nullptr, *nr = nullptr;
        Node(ll l, ll r): l(l), r(r) {
                tree = 0;
                ms = -1;
                madd = 0;
                maddp = 0;
        }
        void make_sons() {
                if (nl != nullptr) {
                        return;
                }
                ll mid = (l + r) / 2;
                nl = new Node(l, mid);
                nr = new Node(mid, r);
        }
        void set(ll x) {
                if (x == -1) {
                        return;
                }
                tree = x * (r - l);
                madd = 0;
                maddp = 0;
                ms = x;
        }
        void add(ll x) {
                tree += x * (r - l);
                madd += x;
        }
        void addp(ll x) {
                tree += x * (r - l) * (r - l - 1) / 2;
                maddp += x;
        }
        void push() {
                make_sons();
                ll mid = (l + r) / 2;
                nl->set(ms);
                nr->set(ms);
                ms = -1;
                nl->add(madd);
                nr->add(madd);
                madd = 0;
                nr->add(maddp * (mid - l));
                nl->addp(maddp);
                nr->addp(maddp);
                maddp = 0;
        }
        ll get(ll x) {
                if (x < l || r <= x) {
                        return 0;
                }
                if (r - l == 1) {
                        return tree;
                }
                push();
                return nl->get(x) + nr->get(x);
        }
        void set(ll ql, ll qr, ll x) {
                if (ql <= l && r <= qr) {
                        set(x);
                        return;
                }
                if (qr <= l || r <= ql) {
                        return;
                }
                push();
                nl->set(ql, qr, x);
                nr->set(ql, qr, x);
                tree = nl->tree + nr->tree;
        }
        void add(ll ql, ll qr, ll x) {
                if (ql <= l && r <= qr) {
                        add(x);
                        return;
                }
                if (qr <= l || r <= ql) {
                        return;
                }
                push();
                nl->add(ql, qr, x);
                nr->add(ql, qr, x);
                tree = nl->tree + nr->tree;
        }
        void addp(ll ql, ll qr, ll x, ll st) {
                if (ql <= l && r <= qr) {
                        add(st);
                        addp(x);
                        return;
                }
                if (qr <= l || r <= ql) {
                        return;
                }
                push();
                ll mid = (l + r) / 2;
                nl->addp(ql, qr, x, st);
                if (ql <= mid) {
                        st += (mid - ql) * x;
                }
                nr->addp(ql, qr, x, st);
                tree = nl->tree + nr->tree;
        }
};

struct segment_tree {
        Node *root;
        segment_tree(ll n) {
                root = new Node(0, n);
        }
        ll get(ll x) {
                return root->get(x);
        }
        void set(ll l, ll r, ll x) {
                root->set(l, r, x);
        }
        void add(ll l, ll r, ll x) {
                root->add(l, r, x);
        }
        void addp(ll l, ll r, ll x, ll st = 0) {
                root->addp(l, r, x, st);
        }
};

const ll MAXC = 2'000'000;

void solve() {
        ll n, q, d, a, b;
        cin >> n >> q >> d >> a >> b;
        vector<ll> dp(MAXC, INF64);
        for (ll i = 0; i < n; i++) {
                ll l, r;
                cin >> l >> r;
                for (ll j = l; j <= r; j++) {
                        dp[j] = -1;
                }
        }
        dp[0] = 0;
        for (ll i = 0; i < MAXC; i++) {
                if (dp[i] != -1) {
                        if (i + 1 < MAXC) {
                                assign_min(dp[i + 1], dp[i] + a);
                        }
                        if (i + d < MAXC) {
                                assign_min(dp[i + d], dp[i] + b);
                        }
                }
        }
        for (ll i = 0; i < q; i++) {
                ll x;
                cin >> x;
                cout << dp[x] << '\n';
        }
}

int main() {
        if (IS_FILE) {
                freopen("", "r", stdin);
                freopen("", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t = 1;
        if (IS_TEST_CASES) {
                cin >> t;
        }
        for (ll i = 0; i < t; i++) {
                solve();
        }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 30ms
memory: 18888kb

input:

2000 200000
500 66309 387245
91 122
793 1029
1127 1131
1304 1611
2007 2039
2601 2701
2906 3052
3253 3263
3495 3609
4157 4225
4283 4283
4757 4766
4786 4847
4885 5086
5326 5342
5607 5750
5847 5877
6093 6230
6548 6793
7206 7308
7413 7419
7752 7780
8244 8410
8501 8515
9335 9447
9512 9514
9602 9906
10076...

output:

-1
-1
1545376776
-1
1355518146
2000000000000000000
-1
1538578776
1124179254
736677313
275840218
-1
314646902
120181124
592802647
1470145222
1194355416
630012616
541479470
1380556431
748297307
1579324340
83071935
-1
547672724
766967273
940718126
967114418
448357717
-1
208077708
264694996
68332763
200...

result:

wrong answer 6th lines differ - expected: '-1', found: '2000000000000000000'

Subtask #2:

score: 0
Runtime Error

Test #29:

score: 0
Runtime Error

input:

1938 1960
999999 47694 9291
2883622 3085639
3674880 3745876
9982198101 9982517489
19960889157 19960925795
19962228551 19962276101
19964301694 19964730442
19964826417 19965369252
19965984922 19966442459
19968019821 19968213820
19968334967 19968392242
19968426638 19968840337
19969017519 19969109591
19...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #44:

score: 0
Runtime Error

input:

198085 196577
999999 1 999999
562622 895604
1799586 1975565
2518299 2941986
4934097 5403130
5755102 5996130
6036200 6112534
6391882 6431514
6451793 6555786
6613625 6621089
7130933 7204522
7335426 7522555
7748545 7784568
8184979 8494887
9066856 9178094
9303615 9384897
9716200 9719420
11693951 1183563...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%