QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104614#5717. 密码锁zaneyu#30 334ms5788kbC++232.5kb2023-05-11 12:25:062024-05-26 02:53:04

Judging History

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

  • [2024-05-26 02:53:04]
  • 评测
  • 测评结果:30
  • 用时:334ms
  • 内存:5788kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-11 12:25:06]
  • 提交

answer

/*input
2 3
3
1 2 1
2 3 2
3 1 3
2
1 2
2 1
1 2

*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//#pragma GCC target("avx2")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=4e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<P.f<<' '<<P.s;
    return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
    REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?",":"");
    return out;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    a%=MOD;
    if(a==0) return 0;
    if(b<=0) return 1;
    ll res=1LL;  
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
int n,k;
int arr[maxn][5];
int mn[5],mx[5];
void solve(){
    int n;
    cin>>n;
    REP(i,k){
        REP(j,n) cin>>arr[j][i];
    }
    if(k>=3){
        int anss=INF;
        REP(i,mypow(k,n)){
            int z=i;
            REP(i,k) mn[i]=INF,mx[i]=0;
            REP(a,n){
                REP(j,k) MNTO(mn[(a+z)%k],arr[a][j]),MXTO(mx[(a+z)%k],arr[a][j]); 
                z/=k;
            }
            int ans=0;
            REP(i,k) MXTO(ans,mx[i]-mn[i]);
            MNTO(anss,ans);
        }
        cout<<anss<<'\n';
    }
    else{
        REP(i,n){
            sort(arr[i],arr[i]+k);
        }
        int ans=0;
        REP(i,k){
            int mx=0,mn=INF;
            REP(j,n) MXTO(mx,arr[j][i]),MNTO(mn,arr[j][i]);
            MXTO(ans,mx-mn);
        }
        cout<<ans<<'\n';
    }
}
int main(){
    int t;
    cin>>t>>k;
    while(t--) solve();
}

详细

Test #1:

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

input:

5 1
20
20828 22671 20646 13184 13779 12445 15192 14863 14396 19238 16788 20325 16831 8559 13417 8768 13227 8760 12456 12091
20
17138 10757 10189 4459 19805 4791 8043 15409 14758 15901 9004 13481 20599 17218 14056 5078 8021 16969 22031 15690
20
26410 25246 16063 9589 20080 21752 25766 14007 12750 231...

output:

14112
17572
16821
21321
16199

result:

ok 5 number(s): "14112 17572 16821 21321 16199"

Test #2:

score: 5
Accepted
time: 20ms
memory: 5788kb

input:

3 1
50000
15429 14039 16730 23945 7044 17994 15646 15950 7744 7726 19830 8000 7607 19562 22681 17139 19133 13561 14539 21246 8476 20813 21139 18999 18270 11950 19511 14822 24627 20644 10619 7699 8058 9578 8425 12058 22166 12276 21095 22645 8087 24264 21082 16567 18500 15489 14629 16114 19826 22286 1...

output:

18373
18000
18000

result:

ok 3 number(s): "18373 18000 18000"

Test #3:

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

input:

5 2
20
3646 6903 10939 9491 14584 16498 7415 10353 8781 10454 703 4651 11986 3700 2186 21659 18792 6774 15283 9422
22629 3204 24229 11810 15271 20496 13170 19867 6105 13572 6657 11440 22722 22564 10168 2797 5798 11753 18320 12720
20
18619 25811 14645 26890 3897 11154 16664 20111 15847 16651 8537 116...

output:

17572
18784
14814
14107
15187

result:

ok 5 number(s): "17572 18784 14814 14107 15187"

Test #4:

score: 5
Accepted
time: 1ms
memory: 3700kb

input:

186 2
5
10809 20957 1456 13581 19134
19871 12718 14451 14783 23041
7
24553 4790 18932 21045 14061 6438 17183
9155 15756 16480 17055 13768 11550 15400
4
12340 23115 28018 8781
16634 10828 1457 21446
7
9619 7632 22338 17091 11090 3368 4366
17684 14282 25007 9194 3144 9944 15465
3
3024 25036 17327
2034...

output:

17678
13003
11384
19194
20499
16143
15079
11508
11891
22699
12676
11250
16873
3238
9264
8040
18134
10772
27251
15001
14812
6575
5499
18396
18795
10752
17672
13273
13915
15178
8303
15337
11707
18835
16270
10944
15953
22359
4914
17434
19001
3224
14155
17053
8670
17906
18767
3696
10036
10580
23062
7636...

result:

ok 186 numbers

Test #5:

score: 5
Accepted
time: 5ms
memory: 3600kb

input:

1357 2
6
1679 1896 8067 24584 3225 2239
14688 13434 4956 688 2751 5016
5
18325 12446 17937 6311 21564
24096 6172 17497 25829 12016
3
9440 752 22972
11570 26214 5969
3
13475 23941 17551
9287 14467 15412
2
20079 827
5314 5994
3
24501 13180 9614
25780 17665 18145
4
16980 22134 5840 14181
16144 7553 773...

output:

21359
13383
14644
10466
14085
14887
14396
19769
12727
14894
9957
19961
16696
14903
12494
14811
13441
15241
5475
15280
10050
15477
10792
15489
14676
21437
19598
12192
15812
10749
24133
15641
24351
20130
8512
11012
19409
7014
18531
9567
17379
4718
13822
15877
11260
17467
12318
12804
19625
4182
20704
1...

result:

ok 1357 numbers

Test #6:

score: 5
Accepted
time: 48ms
memory: 4532kb

input:

3 2
50000
7513 17243 9697 14636 12922 14859 12193 5056 13705 14408 13089 11378 14342 14499 15298 9625 22287 6924 7449 7005 13845 14641 18588 7768 17917 8750 15618 18464 13925 8818 17391 13200 2575 11253 4899 12707 7147 18547 8379 17524 11779 19107 23448 10551 9856 5503 8494 1692 14681 13130 17456 15...

output:

18000
18000
21622

result:

ok 3 number(s): "18000 18000 21622"

Test #7:

score: 0
Wrong Answer
time: 17ms
memory: 3572kb

input:

5 3
10
16030 9693 27756 24507 23211 17464 8887 7416 13135 4895
17169 11454 10400 13490 11738 22678 15050 29009 12184 12183
6893 16992 11689 16565 26352 8380 18580 20848 9410 21743
10
1128 13324 10854 697 15189 7294 1871 12509 18641 18737
8263 13121 15061 18066 16059 11121 24606 17909 1413 9992
12404...

output:

21593
22735
20804
23871
19485

result:

wrong answer 1st numbers differ - expected: '16826', found: '21593'

Test #8:

score: 0
Time Limit Exceeded

input:

10 3
50
12127 17615 4504 20695 16125 18833 13652 5613 8019 15730 16385 3568 14282 14276 13925 16974 8261 24045 9779 1487 3759 15923 7152 21549 26107 14901 14057 5048 12826 6651 12380 18877 17171 4811 18423 22750 12101 8463 7906 20052 9943 4320 11309 23876 6387 7655 3242 14459 14963 6580
20320 8545 2...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

492 3
6
8092 24146 5245 25301 8773 26713
20068 26047 4375 21461 28935 4037
28742 5614 21217 11156 23813 14955
4
26596 4665 12954 28516
2539 28719 26192 23894
9531 18883 18267 9946
4
15563 2548 22395 29261
1483 598 24912 12610
17817 9629 17119 7397
5
11066 7676 29263 9309 5342
18273 24030 25203 5102 ...

output:

22676
24057
21864
19016
19866
15692
18029
17089
20826
19468
21913
17675
19817
26485
21464
11900
23628
20088
22566
13467
27106
20747
24787
13924
13319
13390
16108
16482
19527
25452
19345
24989
16000
21001
19775
23006
20025
15295
17700
18151
12453
11634
19283
19977
14000
14483
12386
21762
13622
19233
...

result:


Test #10:

score: 0
Time Limit Exceeded

input:

2823 3
7
11008 15379 3474 23505 21289 13545 21951
14190 11309 11018 12827 20349 17613 20448
14242 15097 16392 7823 18077 27988 12213
4
10305 19014 15560 26972
21128 9755 5367 23887
17563 15511 13210 12065
5
7016 12729 24261 5979 12169
21967 10993 25792 11527 11476
21349 2172 20428 22930 23721
6
1562...

output:

15682
14907
16951
21255
11964
21987
22966
25915
12556
25584
15073
27677
17270
20692
17071
10587
20546
18402
18357
14509
20375
16608
8089
22624
18946
19036
10529
20581
15000
19537
23826
22372
24669
23583
12748
22465
18905
21921
16019
18412
17751
19008
17111
19661
19560
26641
21641
19957
24499
22672
2...

result:


Test #11:

score: 0
Time Limit Exceeded

input:

4 3
30000
8497 11286 8353 2876 13129 10774 10578 13288 16631 14892 4744 10355 11083 16465 12953 9099 9278 12561 12862 13392 1500 17077 11412 4467 14626 14772 8321 8327 3999 11277 13029 4212 1734 13474 13656 8398 762 10438 14080 15473 3866 7574 10692 16389 4413 9044 18604 1591 10649 14576 10155 10361...

output:


result:


Test #12:

score: 0
Time Limit Exceeded

input:

3 3
50000
19199 27507 19780 17075 20200 20902 22589 12623 21750 21336 4538 24298 18509 16201 16796 6650 19468 19507 25451 27321 18009 23942 24617 24422 26676 8908 4600 11408 20067 23198 23582 16086 21592 19845 18972 17985 11853 25099 28717 27759 10596 23082 27902 19323 16693 8408 26792 20131 22735 2...

output:


result:


Test #13:

score: 0
Wrong Answer
time: 334ms
memory: 3568kb

input:

5 4
10
12871 9817 14695 11872 16291 27028 1392 12572 10409 3017
16310 28902 7458 24546 13098 2633 26901 14337 17441 63
26236 2514 24674 23157 9327 13531 25862 26834 24256 21476
22242 24748 23021 17878 26324 12312 3909 28308 3462 20168
10
20846 29205 14900 19250 722 6157 15661 8441 17182 11169
3390 1...

output:

26388
26520
23087
28788
26806

result:

wrong answer 1st numbers differ - expected: '24685', found: '26388'

Test #14:

score: 0
Time Limit Exceeded

input:

10 4
50
19704 7323 15828 22182 10893 7859 16948 16603 28637 8205 12361 2532 5845 23202 10647 14169 15901 24468 1029 25019 26328 18995 14057 6145 13869 15274 5361 22018 4967 1745 16752 19883 926 78 6747 7515 8391 21114 28634 18985 27576 5184 3502 25152 21983 2702 11587 9661 9052 23658
5746 9465 16337...

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

296 4
5
14984 9981 9017 21474 22589
15490 4551 17062 14214 18005
5994 11883 5919 13543 16909
18835 23523 17149 11464 14979
6
14169 24435 27207 2521 14770 2155
8254 9241 12877 22826 18706 14972
19413 12325 7660 19399 13082 17109
21888 14786 17154 13755 1801 9630
7
12587 18433 18081 13142 19835 14986 ...

output:

18972
20305
25498
20860
21073
19072
19399
26181
24204
27621
21378
28424
26705
23806
26738
24628
19410
24022
17754
25838
19108
19719
22720
16299
20533
28438
24290
27234
26630
25381
24670
22216
17604
28020
19843
26395
22753
18894
25095
27743
27032
15945
19649
16345
19922
28299
20202
19519
25337
22116
...

result:


Test #16:

score: 0
Time Limit Exceeded

input:

556 4
6
24538 1561 15955 25462 13820 18425
23525 16200 7272 8057 14559 13522
4043 13481 11449 26789 19442 22612
19442 17815 15054 14372 24215 15908
7
4992 21533 18540 20730 21070 25918 14971
18953 15648 18255 12969 20983 12375 20955
4379 23010 25490 28045 16038 13733 27907
7885 27116 20057 29239 136...

output:

20495
16270
26551
25929
16987
19773
23684
21830
14368
26441
18686
18292
20976
26649
21435
17324
22737
17963
26618
26726
24911
23994
20484
24289
20896
23448
17732
13989
26423
21312
26509
22664
19428
26373
26041
21595
16591
28370
28181
27490
25466
16656
22129
22315
24963
15712
18757
16205
25776
24685
...

result:


Test #17:

score: 0
Time Limit Exceeded

input:

910 4
5
18495 4213 7072 24451 5053
24983 1518 19953 25740 1087
4368 10700 8715 18200 28641
14575 2496 27461 27488 13358
4
9653 12755 22556 17654
21198 18496 17358 19398
27223 11305 27527 21344
22554 19509 8064 23976
7
1138 20361 16799 21891 18013 21953 4783
12601 3538 13276 22157 13538 10272 24627
2...

output:

27554
19463
24949
20034
17550
16993
24606
19146
27850
23380
27331
22994
20996
27243
24910
24349
22425
24640
21270
27303
26646
14157
19636
22740
21017
25625
25358
18876
26571
22673
28071
17066
17532
24458
29481
27903
16832
28119
27951
22115
19246
24582
21276
8458
20523
17558
19392
19025
16266
28092
2...

result:


Test #18:

score: 0
Time Limit Exceeded

input:

1826 4
5
12038 3573 20463 6119 19486
9769 26360 9873 3880 27288
14634 18318 2181 14462 7044
18465 4615 19511 28217 543
5
29712 7598 12660 5404 13631
8149 15497 14057 12916 16856
23561 10256 5404 6465 13656
6258 12169 17157 15896 14018
6
10545 25243 9487 14739 13377 3270
7836 5934 29067 27149 19583 1...

output:

26745
23454
28137
26241
21099
24909
13961
25631
18383
22995
24585
21112
26341
15758
21835
20233
13235
20646
24847
24489
22258
26425

result:


Test #19:

score: 0
Time Limit Exceeded

input:

1834 4
5
14031 15017 11718 8584 24580
2938 13523 5087 3420 27335
16189 5418 9070 14669 21628
22686 16121 15677 21857 26168
4
13628 4601 13896 2382
5508 5343 25068 22533
17027 14789 2864 19773
26676 3034 11148 26438
5
20602 13848 6353 13350 23468
26366 10523 24372 8484 24138
4007 21029 5227 14962 231...

output:

19748
24056
23963
22091
18805
26770
23383
21347
25812
19353
18460
25318
18785
24719
27108
21999
26557
22717
21853
19308
24838
15363
24545
22475
29168
19913
20789
28123
25041
22061
19974
25878
27194
19803
21451
21741
26191
25877
22881
18055
25408
17470
16367
26087
18443
24132
11654
20475
26166
26573
...

result:


Test #20:

score: 0
Time Limit Exceeded

input:

3 4
10000
27024 14111 22404 5025 23580 12815 13934 2337 12175 11404 6514 12919 22433 27537 25780 7967 6642 17225 21192 14830 1691 1887 11039 7793 3178 8346 22904 16381 5296 29290 20246 12878 21843 11597 11199 7069 14778 10902 24331 15641 21285 16597 16428 20494 26998 7139 14721 10644 25003 13823 268...

output:


result: