QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606350#1820. Contest Constructionnickbelov#AC ✓1ms4152kbC++202.7kb2024-10-03 01:30:562024-10-03 01:30:57

Judging History

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

  • [2024-10-03 01:30:57]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4152kb
  • [2024-10-03 01:30:56]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
ostream_iterator<T> oit(const string &s = " "){ return ostream_iterator<T>(cout,s.c_str()); }
inline auto rep(int l, int r) { return views::iota(min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }
inline auto per(int l, int r) { return rep(l, r) | views::reverse; }
inline auto per(int n) { return per(0, n); }
inline auto per1(int l, int r) { return per(l, r + 1); }
inline auto per1(int n) { return per(1, n + 1); }
#define A(a) begin(a),end(a)
inline auto len = ranges::ssize;

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;
#define K first
#define V second

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vii = vector<vector<int>>;
typedef vector<ll> vll;
using pll = pair<ll,ll>;
using pii = pair<int,int>;

constexpr ll NN = 2e5, M = 1000000007, L = 20;

ll f1[NN], f2[NN];
ll inv(ll a, ll b=M) { return 1 < a ? b - inv(b % a, a) * b / a : 1; } // inv a mod b
ll choose(ll n, ll k) { return f1[n] * f2[k] % M * f2[n - k] % M; } // n choose k

void run()
{
    ll n,k; cin >> n >> k;
    vll a(n); for(ll &x : a) cin >> x; ranges::sort(a);

    ll dp[n][n][k+1] = {}; for(auto &v : dp) for(auto &vv : v) for(auto &x : vv) x=0;

    for(int i : rep(n)){
        for(int j : rep(i)){
            for(int k : rep1(3,k)){
                for(int jp : rep(j))
                    if(a[j]+a[jp] >= a[i]) dp[i][j][k] += dp[j][jp][k-1]; 
            }            
            //k==2
            dp[i][j][2] += dp[j][j][1]; //previous state for 2 is always 1 which is like weird
        }
        //k==1
        dp[i][i][1] = 1; //can always start a len1 sequence here, idc about j
    }
    
    ll ans = 0;
    for(int i : rep(n)) for(int j : rep(n)) ans += dp[i][j][k];
    cout << ans << '\n';    
}

int main()
{
    //KING OF THE WORLD...... U.W.T.B
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    run();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3444kb

input:

5 4
2
1
4
3
5

output:

4

result:

ok answer is '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

8 5
1
2
3
5
8
13
21
34

output:

4

result:

ok answer is '4'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3952kb

input:

50 18
543
654
76
654
45
89879
5465
52534
65
76
987
54
342
76
897
98
78
765
653
763
532
654
543
432
653
754
876
9786
653
836
346
76
235
765
2543
765
443
76
7654
25
65
765
543
543
7654
54
3
76
43
54

output:

10783193

result:

ok answer is '10783193'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

50 18
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19

output:

18053528883775

result:

ok answer is '18053528883775'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

50 3
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19

output:

19600

result:

ok answer is '19600'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

50 18
7295433
4122373
116406027
454116124
42443372
317888
199216502
56260397
610004
13392063
283357040
508349280
89413497
70331028
368879117
111784767
4593692
29343700
23021361
279434982
22390765
45945161
286368123
209208600
21877989
548877618
4162222
137007556
167875908
146173950
313180214
30870818...

output:

144239641210

result:

ok answer is '144239641210'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

50 18
3716814
568135643
462160899
26805431
231695644
5601526
502786118
39783184
35426663
186422202
62425419
101059185
665437020
635618232
51542527
396465857
16859236
7425591
6756174
19816493
304091886
215495907
171198606
106533934
23764675
163466813
4479298
44408003
7645949
15198717
73536966
1483222...

output:

596113488536

result:

ok answer is '596113488536'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

50 18
283024896
152603423
11426132
234806568
34524227
18658291
542799424
62907242
116203436
25415293
123271745
372299577
4660528
8132023
11257429
7023013
5723335
126878926
37145542
128854220
87434920
58277670
220888000
204051291
43385646
34364783
14491819
3583887
422452342
352166988
22274761
2998060...

output:

650569073161

result:

ok answer is '650569073161'

Test #9:

score: 0
Accepted
time: 1ms
memory: 4152kb

input:

50 18
518983379
161261581
233740320
63990718
1161766
19769681
214374511
267851575
31916563
917480
71355983
71438920
6667292
21529994
20838999
37065074
2361475
502996567
16266200
164062179
16079469
6910382
4115517
11504084
7028100
310973025
123304215
136428223
234122549
18130324
21790647
54624354
726...

output:

523676516787

result:

ok answer is '523676516787'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

50 18
57666270
1159218
336251104
129466393
2004008
84645694
222646363
35751
16858266
216878243
55993065
80539635
55452100
70464080
143170709
131663398
120164194
382468753
48877550
338314052
66682226
63657147
22053549
126138315
897932414
4831119
11516705
14487645
37734172
149495136
11756744
127004803...

output:

144283310470

result:

ok answer is '144283310470'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

50 4
160895411
133753403
24170951
340889608
103160738
1245670
529012
14206884
10024066
2277830
253132949
33201663
301074895
13233668
255259851
82136942
75303474
141124335
51809216
78139988
148798277
31992136
7980940
183241772
117326858
21895456
92419
146958913
54038400
162803585
472892287
1718076
41...

output:

18594

result:

ok answer is '18594'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

50 5
4714560
73523659
297216094
523617033
15650792
45996997
38959045
23006547
225213776
4282851
98141570
239793683
124440915
47821779
28479221
476587361
102861573
13504383
309724799
50677850
33789624
69478648
12882520
313306636
23164396
41780840
32218332
239401178
29691399
81969108
9642447
6812843
7...

output:

142332

result:

ok answer is '142332'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3968kb

input:

50 7
7212185
89967209
118736951
67603391
206951937
11662438
176579927
75912703
151673308
79102167
87582067
224089353
50919992
508344372
31664598
12189945
123288192
5654969
19508263
459423221
44982500
102586884
140960833
308378815
216407698
112679266
116410233
59227074
20686731
198668231
517153234
13...

output:

11005572

result:

ok answer is '11005572'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

50 5
78992558
20900606
547083083
66174583
45321166
62884504
119031713
64231289
19363623
90983177
164563975
3113683
174993272
129275214
474853111
110377017
504518112
263472888
74742274
178769089
72661056
22713406
160180628
40627740
2462697
3343269
63549971
22592341
427599504
6574851
15760803
734586
2...

output:

63503

result:

ok answer is '63503'

Test #15:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

50 12
102938510
142012747
380065
179164691
737717892
251937304
295610346
21314
5882257
20485156
5730920
146970036
19642097
424955645
163906140
16742316
12009421
374643689
95856978
18877704
438324875
194527107
2619322
19371194
68818096
433606
404928525
19767487
26831020
23851623
105828223
86974448
36...

output:

596655843

result:

ok answer is '596655843'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

41 17
25215838
9249186
10565052
77917863
66649914
37670464
38367976
39156515
72271688
82569137
215409505
37199653
128955494
12980702
139996410
6211992
1167092
291725158
242352776
76786184
95399187
217359406
241534470
731288594
8398269
69683265
246895523
26419611
170319625
100681488
397712972
4552682...

output:

5732675960

result:

ok answer is '5732675960'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

50 13
61931407
341704599
171884663
309716000
38860051
1909972
208959832
79620359
125005624
2027588
4220857
62570080
7896576
4508976
149359230
67835433
79198912
69109400
19133269
280408739
3217911
1314057
24768376
43347299
1052972
64246656
10744844
688158546
15249889
12078768
6814665
9939048
40186916...

output:

295639415

result:

ok answer is '295639415'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

12 9
427611936
87433585
6351505
10445202
79533273
345081318
21730411
107753046
9034515
55516354
33528234
615757

output:

0

result:

ok answer is '0'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

19 16
227041629
154098404
254470885
6902171
238443211
147821630
183625244
71117051
182312095
52163318
13847176
198545690
331731449
154695040
91974598
207538517
116381815
149148831
131636954

output:

17

result:

ok answer is '17'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

37 8
66233394
216889
26334716
188509248
19471604
74838914
19177057
122552044
18784075
21016552
125399695
36611533
227708120
8089590
31944730
225208809
190115174
41547203
247710457
7824707
65542628
108764859
52971101
19190856
25601368
228598252
155293782
93252132
146375633
97492451
25105673
289792622...

output:

2545587

result:

ok answer is '2545587'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

42 18
1
2
4
7
12
20
33
54
88
143
232
376
609
986
1596
2583
4180
6764
10945
17710
28656
46367
75024
121392
196417
317810
514228
832039
1346268
2178308
3524577
5702886
9227464
14930351
24157816
39088168
63245985
102334154
165580140
267914295
433494436
701408732

output:

0

result:

ok answer is '0'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

3 3
1
10
100

output:

0

result:

ok answer is '0'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

3 3
1
2
3

output:

1

result:

ok answer is '1'