QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#723648#9609. 幽默还是夢hos_lyric#25 531ms4292kbC++142.8kb2024-11-07 23:25:582024-11-07 23:25:58

Judging History

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

  • [2024-11-07 23:25:58]
  • 评测
  • 测评结果:25
  • 用时:531ms
  • 内存:4292kb
  • [2024-11-07 23:25:58]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


constexpr Int INF = 1001001001001001001LL;

int N, Q;
vector<Int> A, B;
vector<int> O, P, L, R, K;
vector<Int> X, Y;

vector<Int> brute() {
  auto as = A, bs = B;
  vector<Int> ans(Q, 0);
  for (int q = 0; q < Q; ++q) {
    if (O[q] == 1) {
      as[P[q]] = X[q];
      bs[P[q]] = Y[q];
    } else {
      vector<Int> dp(2 * (R[q] - L[q]) + 1, INF);
      dp[0] = 0;
      for (int i = L[q]; i < R[q]; ++i) {
        for (int k = 2 * (i - L[q]); k >= 0; --k) {
          chmin(dp[k + 1], dp[k] + as[i]);
          chmin(dp[k + 2], dp[k] + bs[i]);
        }
      }
      ans[q] = dp[K[q]];
    }
  }
  return ans;
}

int main() {
  for (; ~scanf("%d%d", &N, &Q); ) {
    A.resize(N);
    B.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%lld%lld", &A[i], &B[i]);
      assert(0 < A[i]); assert(A[i] < B[i]);
    }
    O.assign(Q, -1);
    P.assign(Q, -1);
    L.assign(Q, -1);
    R.assign(Q, -1);
    K.assign(Q, -1);
    X.assign(Q, -1);
    Y.assign(Q, -1);
    for (int q = 0; q < Q; ++q) {
      scanf("%d", &O[q]);
      if (O[q] == 1) {
        scanf("%d%lld%lld", &P[q], &X[q], &Y[q]);
        assert(0 <= P[q]); assert(P[q] < N);
        assert(0 < X[q]); assert(X[q] < Y[q]);
      } else if (O[q] == 2) {
        scanf("%d%d%d", &L[q], &R[q], &K[q]);
        ++R[q];
        assert(0 <= L[q]); assert(L[q] < R[q]); assert(R[q] <= N);
      } else {
        assert(false);
      }
    }
    
    const auto ans = brute();
    for (int q = 0; q < Q; ++q) if (O[q] == 2) {
      printf("%lld\n", ans[q]);
    }
  }
  return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 4088kb

input:

3 5
3 6
2 7
3 6
1 1 1 6
1 0 2 3
1 1 4 9
2 0 1 4
2 0 2 4

output:

12
9

result:

ok 2 number(s): "12 9"

Test #2:

score: 5
Accepted
time: 0ms
memory: 4056kb

input:

3 5
5 6
5 6
5 10
2 1 2 1
1 2 5 9
1 1 1 2
2 0 1 3
1 0 4 8

output:

5
7

result:

ok 2 number(s): "5 7"

Test #3:

score: 5
Accepted
time: 0ms
memory: 3792kb

input:

5 3
1 6
4 5
1 3
4 6
4 7
2 0 1 2
2 3 3 1
2 0 4 6

output:

5
4
13

result:

ok 3 number(s): "5 4 13"

Test #4:

score: 5
Accepted
time: 0ms
memory: 3800kb

input:

14 14
137604651 148051578
362722420 701127241
112668315 125437888
287900155 387914570
372764764 835453510
487901436 886003378
220152717 420521021
398973222 512891403
388384759 595247888
89781009 585869215
26792323 118929846
336453982 364990768
321824819 613043271
388186725 818512652
1 6 181262309 25...

output:

1361305890
625931363
196861445
1202933382
575465932
450028044
456536086
253166599
1485150610
196861445
748691543

result:

ok 11 numbers

Test #5:

score: 5
Accepted
time: 0ms
memory: 4052kb

input:

14 14
6 20
5 8
6 22
6 20
20 31
18 35
16 22
7 25
15 21
2 3
2 18
5 22
20 27
5 8
2 3 9 12
2 4 8 7
2 0 7 4
2 0 1 3
1 11 1 18
2 8 10 4
2 1 5 9
1 6 10 16
1 5 12 19
2 6 8 4
1 2 8 27
2 1 11 14
2 2 12 5
2 7 9 6

output:

122
81
20
14
20
99
37
83
12
49

result:

ok 10 numbers

Test #6:

score: 5
Accepted
time: 0ms
memory: 3804kb

input:

14 14
3 22
7 15
11 12
16 29
17 36
9 22
11 14
15 19
7 24
20 30
2 7
14 17
1 8
15 24
2 6 12 2
1 8 13 24
1 6 11 18
1 1 8 24
1 3 14 29
1 5 17 33
1 5 3 14
1 1 7 15
2 0 11 18
1 10 14 22
1 2 15 28
2 4 4 1
2 9 13 1
1 6 14 27

output:

3
143
17
1

result:

ok 4 number(s): "3 143 17 1"

Test #7:

score: 5
Accepted
time: 0ms
memory: 3768kb

input:

14 14
257829907 724715537
108651452 258598766
94683229 173211791
479210658 582119116
54540156 428302979
52455936 383613089
490920498 513399791
352653592 701946471
340154330 398349800
121686359 192733077
88773311 129421949
320698287 575819706
170879293 344150256
302356504 521941463
2 3 12 10
1 8 2452...

output:

1171651174
429151118
2188227897
575819706
284981414
1615206255
320698287
1593325327
129421949

result:

ok 9 numbers

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 5
Accepted
time: 3ms
memory: 3844kb

input:

300 300
236272593 367977426
193245445 202346765
154060783 238627896
266263504 714515068
326570377 765576129
319118394 352576872
105744828 271847570
1123063 437252936
292326814 652693639
119178460 320083080
392059409 484903780
178885480 591157929
273931331 692199866
156093219 524526946
323752415 8226...

output:

12903467467
12140459036
15087634605
27198807498
29428660401
6169823972
15045538543
4383591
2359669927
1063857724
694501138
24620774975
9566547346
65353375060
10241685703
121125504
13264370395
9581854028
14132735946
77877326550
285563821
9085006335
18424522279
7729941213
6497908382
28538021992
662892...

result:

ok 146 numbers

Test #9:

score: 5
Accepted
time: 0ms
memory: 3852kb

input:

300 300
244663179 509035792
332903389 613341357
161987994 606940171
336723050 507606507
145455363 204317531
169573385 379283435
177050397 562868538
431733852 523770709
212243619 281715538
83255800 160178888
294475851 697375668
343483612 775166562
281248069 495482283
138995617 554668578
194259365 216...

output:

40254603
16369627943
2448905059
1868439239
1057562633
7471849467
14589706661
50073674230
3644726912
63713269
13049201228
16762172359
17712958839
18411593284
8546622062
33190286201
18793253982
10814998349
5882894800
15312531098
52138307
13762650523
1488748067
22823558723
11962399128
41833685078
40483...

result:

ok 143 numbers

Test #10:

score: 5
Accepted
time: 3ms
memory: 3836kb

input:

300 300
72911832 469485383
105942845 273018682
232457225 578806174
269721902 378206843
103384491 595940124
364126138 549620383
468136415 829403771
79997976 363085297
320307362 535761950
395259575 761297849
241479722 357024290
411307155 562957441
288347269 448717572
256345663 393867710
363610578 4187...

output:

6913154278
2842330034
2185597552
32914182697
3349781269
33240231006
13292793883
35013050874
36781788100
4492425969
733292842
2680419448
28899224522
178152769
3612931177
15062161441
4227210687
2083096048
62437668974
9145335161
20152648
1755242090
462627834
3738164822
3792823081
59119687341
1413096882...

result:

ok 170 numbers

Test #11:

score: 5
Accepted
time: 3ms
memory: 3836kb

input:

300 300
17 28
7 19
17 19
8 12
2 10
15 22
5 19
19 31
8 25
19 22
6 12
1 12
16 22
4 5
10 27
10 12
16 23
16 35
5 12
4 16
12 27
8 16
17 19
10 24
10 26
16 18
13 14
12 17
7 24
14 29
11 23
14 33
8 24
5 21
2 16
2 17
19 26
2 17
14 16
11 17
7 17
3 10
4 11
14 34
11 13
12 24
15 27
10 25
19 23
2 22
5 11
12 32
3 1...

output:

3276
1662
1369
243
286
290
3411
346
1563
88
787
441
295
223
2238
2632
1012
126
1129
10
621
30
237
1111
1117
596
555
152
251
444
659
207
712
1934
82
112
320
222
1136
1417
598
19
114
1414
576
201
1815
4037
1034
373
515
428
65
181
84
135
285
1
89
258
2
160
236
794
249
61
1770
21
430
103
48
44
405
113
1...

result:

ok 140 numbers

Test #12:

score: 5
Accepted
time: 0ms
memory: 4132kb

input:

300 300
17 29
20 26
2 22
3 11
19 37
7 26
14 23
3 16
7 10
13 20
5 19
14 24
2 4
1 8
19 36
11 30
1 2
20 29
13 28
12 24
18 34
13 23
20 26
20 36
11 22
11 31
13 14
20 34
2 4
11 14
5 22
13 23
12 13
7 23
7 23
15 26
20 29
2 12
6 11
19 25
9 13
5 10
16 20
17 30
7 11
18 25
11 14
6 26
2 16
1 2
18 30
10 18
10 16
...

output:

203
455
2
3824
2036
7
217
2680
502
3
27
496
78
544
1126
61
1058
311
1797
1218
164
3114
50
1536
130
3433
5
2451
83
2132
216
710
449
3189
255
1108
1088
498
163
1647
179
516
2
262
2605
160
459
293
481
211
1963
441
404
330
126
45
697
64
36
892
393
56
117
3593
726
3051
654
5
1063
1922
1263
956
200
259
12...

result:

ok 142 numbers

Subtask #3:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #13:

score: 15
Accepted
time: 504ms
memory: 3932kb

input:

2000 2000
492156297 891105567
457854002 671145682
119875716 213459413
129540041 445263628
45723424 297701781
243530727 413420086
343868745 465766786
39585054 342872573
245699946 297595828
283288483 332910548
19248601 74422280
305868175 725593305
137155918 635077642
186537009 320193545
449764641 9168...

output:

769333315
31814430233
192156363
10731582114
310909096915
205483963778
124233092017
268012585576
164616784041
38053660249
9480536842
158352240104
407150954886
17063476029
82258316259
21369738423
3266683042
272282626186
556810418612
75466361119
398580395
186178907785
564338317766
145374417881
27185904...

result:

ok 965 numbers

Test #14:

score: 15
Accepted
time: 469ms
memory: 3984kb

input:

2000 2000
199918641 456527544
260775423 495168036
454126239 624980472
25503786 95958076
23049625 205204895
398321843 644801632
23803572 367932566
63791123 443652304
16717424 461899786
57182702 134288560
7367915 413777915
461864555 750003900
221881777 613181615
121094 462492090
235789679 722704353
13...

output:

119394915468
17941562480
279125740743
2233864829
106860370137
54758865798
143679361393
1877398337
779567529317
40363989047
263489643774
55000571549
7132978602
18526821294
222577978228
15638261704
161092153447
156826695129
36606198617
220813405946
60955688238
275212249345
221129445815
59748325945
163...

result:

ok 969 numbers

Test #15:

score: 15
Accepted
time: 489ms
memory: 4044kb

input:

2000 2000
497204382 995759939
221489796 251373672
498330228 556418029
450120891 715563300
307205005 406128293
215762347 678991374
86646319 139613276
8016302 35662129
25286265 324810382
371712021 641916776
63661846 497446528
458951932 868655385
10641798 205365852
319615379 615786917
90106107 41041485...

output:

13741251535
23390871836
13803366145
6846598624
164727658887
161453438707
151504751806
4382792638
1888841444
43321838168
118063814074
62184098093
132756597809
7616990021
65196341872
104234091197
148562690039
161010686208
108370261703
185354238433
202041650695
205544165494
65269540158
14074240805
5254...

result:

ok 991 numbers

Test #16:

score: 15
Accepted
time: 531ms
memory: 3996kb

input:

2000 2000
10 11
16 34
10 16
9 29
19 39
4 22
3 14
5 25
3 5
17 18
13 20
12 13
1 10
18 38
6 21
13 30
18 38
2 8
12 23
8 15
11 14
4 7
5 20
7 21
9 11
18 27
8 17
13 20
5 23
9 20
1 10
13 18
14 24
6 12
7 9
18 20
11 13
16 25
3 4
9 11
16 17
11 19
3 8
16 28
18 30
11 14
15 16
9 20
14 33
15 28
9 15
9 25
2 10
4 12...

output:

5957
212
178
14513
20720
130
2831
16927
528
12
3885
370
6136
612
251
9095
1576
938
1366
6681
9451
2684
1642
13112
15777
1709
183
5155
8464
689
3061
751
20692
1057
11712
1108
8393
26590
18884
700
6835
19272
3232
2930
5193
14623
1671
131
265
9420
608
10727
4979
3214
133
3276
79
7704
1353
14491
636
31
...

result:

ok 1000 numbers

Test #17:

score: 15
Accepted
time: 518ms
memory: 4292kb

input:

2000 2000
2 21
2 13
20 30
12 16
20 35
11 29
14 24
18 24
20 40
17 36
18 24
5 14
1 4
17 32
14 17
9 28
17 23
18 34
12 15
2 6
15 25
17 26
16 34
8 14
3 7
10 16
9 18
19 37
10 23
8 21
3 7
18 30
11 22
11 13
18 22
7 9
14 19
17 26
9 19
7 24
7 21
10 22
7 24
19 22
13 27
5 13
16 31
20 23
6 19
4 10
5 23
8 15
16 2...

output:

2255
1934
415
3781
33403
12881
4926
2129
20
420
9383
18403
6987
432
136
17871
692
4679
210
14670
1077
239
123
4675
7014
507
9103
751
15
168
26078
1139
25299
8914
6065
199
11315
7903
17344
4695
2851
9185
1045
870
2899
15438
2382
30
1680
40
8854
7996
2726
21484
4416
4461
1167
202
7877
169
7871
281
134...

result:

ok 989 numbers

Subtask #4:

score: 0
Time Limit Exceeded

Test #18:

score: 0
Time Limit Exceeded

input:

100000 100000
14 26
20 23
12 27
12 26
19 31
19 36
19 31
4 20
6 10
10 20
3 6
5 8
12 23
2 14
11 15
7 12
4 8
3 11
17 32
5 21
20 37
14 23
11 15
1 8
10 18
9 26
15 34
14 20
4 19
1 20
13 18
1 5
9 21
3 6
12 18
18 24
2 12
10 22
7 21
4 7
13 20
11 23
19 37
5 18
15 18
12 26
8 10
7 23
7 26
17 23
4 15
15 22
2 10
...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Time Limit Exceeded

Dependency #3:

100%
Accepted

Test #28:

score: 0
Time Limit Exceeded

input:

80000 80000
225354689 357421712
256970283 623358975
178383251 591207393
182615894 514317155
100808700 223792723
474091630 934549627
299874379 640509921
465635430 870489677
66892738 194064485
159834884 348499459
238168819 335814593
75986241 170063921
331860127 555061772
141800677 377649941
472424012 ...

output:


result:


Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%