QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#681854#6237. 寻宝游戏propane0 91ms8956kbC++201.6kb2024-10-27 12:28:102024-10-27 12:28:10

Judging History

This is the latest submission verdict.

  • [2024-10-27 12:28:10]
  • Judged
  • Verdict: 0
  • Time: 91ms
  • Memory: 8956kb
  • [2024-10-27 12:28:10]
  • Submitted

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
using LL = long long;
const int mod = 1e9 + 7;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int n, m, q;
    cin >> n >> m >> q;
    vector<string> s(m, string(n, '0'));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> s[j][n - 1 - i];
        }
    }
    vector<int> id(m);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int a, int b){
        return s[a] < s[b];
    });
    vector<int> rk(m);
    for(int i = 0; i < m; i++){
        rk[id[i]] = i;
    }
    vector<int> val(m);
    for(int i = 0; i < m; i++){
        for(auto c : s[i]){
            val[i] = (val[i] * 2 + (c - '0')) % mod;
        }
    }
    int all = 0;
    for(int i = 0; i < n; i++) (all = all * 2 + 1) % mod;
    while(q--){
        string s;
        cin >> s;
        int mx = 1e9, mn = -1;
        for(int i = 0; i < m; i++){
            if (s[i] == '0'){
                mn = max(mn, rk[i]);
            }
            else{
                mx = min(mx, rk[i]);
            }
        }
        if (mn >= mx) cout << 0 << '\n';
        else if (mn == -1){
            cout << val[id[mx]] << '\n';
        }
        else if (mx > n){
            cout << (all - val[id[mn]] + mod) % mod << '\n';
        }
        else{
            cout << (val[id[mx]] - val[id[mn]] + mod) % mod << '\n';
        } 
    }

}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3768kb

input:

20 30 1
010100001010100101010101010111
001111111001111100010111111000
011100111101000011111111111001
010110010011100010110110000111
001001100010011111000001101011
000011101011011010100101110011
001100000111001110100101101110
000101111001100111010111110101
000000111010010011010110110011
1001111000111...

output:

351117

result:

wrong answer 1st numbers differ - expected: '1669', found: '351117'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3616kb

input:

1000 16 1000
0011100011111111
0011011010111010
0110011110110011
1010011111000011
1001011001100111
1111001101000010
0001000110101101
1100000111101010
1011100111111111
1110100010110001
0111010001101010
0001111111011101
0010111001111111
0000000100010011
0011100111010000
1110110111001001
110100000000100...

output:

857888648
68821743
862357315
435679482
167927461
455884328
455884328
435679482
329191893
68821743
0
455884328
453074185
455884328
435679482
12465940
956544033
210043177
857888648
857888648
857888648
0
167927461
862357315
700228207
329191893
68821743
329191893
329191893
12465940
956544033
700228207
9...

result:

wrong answer 1st numbers differ - expected: '546311852', found: '857888648'

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 3852kb

input:

1000 16 1000
0101100010010000
1000111011001101
1101001111111010
1110101100010001
0101100000000101
1010011110111111
0111111110011010
0010110101111100
1010100000111110
1000110000011010
1110010100011111
0001000111110111
1010011110110100
1100010011000100
1111110111100011
0111011101100111
100011111111101...

output:

911693988
628057030
520500655
152386859
0
949829617
949829617
949829617
651886608
0
767563562
567224118
51663599
567224118
504514244
655570883
628057030
653311634
651886608
911693988
655570883
762981745
651886608
0
0
655570883
767563562
520500655
628057030
0
762981745
628057030
655570883
520500655
6...

result:

wrong answer 1st numbers differ - expected: '600117192', found: '911693988'

Test #4:

score: 0
Wrong Answer
time: 9ms
memory: 4164kb

input:

500 1000 1000
0011010011000100101111101101101101011100000001011001010101111101011100101111100001100000101101010101100100011001011111110011101110010111111100100000001111111100000110000110101010001101000101010000010100111101111011010110101101000110000111010011011001111000100001011010100100011000110110...

output:

324180856
209138641
606477942
0
958723037
503914659
859772532
285889785
537262220
765224140
86481620
0
599329889
62403003
223436325
615880199
56184840
0
606646392
86481620
280233546
951074515
901066820
495226355
295995262
318838879
397386814
841674978
0
0
184278953
452676554
728623746
747987884
2093...

result:

wrong answer 1st numbers differ - expected: '714663864', found: '324180856'

Test #5:

score: 0
Wrong Answer
time: 9ms
memory: 4048kb

input:

500 1000 1000
0001001101001100001110001100001010101111101011011011011100101001010101001111101111100101110011011010111010110100101010111100101110011101000100010000001111111010101110011001011111011110111111100011001010111100101110101101000100110011100101101101010011101111010001000111101111000111000110...

output:

51389481
208921884
203810130
457905314
838823764
459958033
433045769
99674661
527900707
887079939
372937510
0
662961762
0
0
141891093
794074520
734061932
274034870
123312323
693541831
754915117
262585116
204912260
764661580
31792038
118974865
613306508
0
435458357
839244847
903351888
576374805
0
294...

result:

wrong answer 1st numbers differ - expected: '441872489', found: '51389481'

Test #6:

score: 0
Wrong Answer
time: 9ms
memory: 4132kb

input:

500 1000 1000
0000011100101100010011000011111000111000011010110101100110100011100010000111101100111110110101101110000001101110100101110000011101011000011000110001010110011100101100010100001000011100101100001101110111111100110101000010001110110001011011110110101110101001011111000111000101010010101001...

output:

263762899
294743637
782762565
790835260
0
227696122
502425569
859109629
7867265
625419989
690855182
0
904407063
0
40682981
0
61709456
0
327046796
577348769
482780640
533094565
0
40238421
0
0
487752921
208480332
657297348
920407413
77674555
580338823
0
0
125179930
91005509
251915364
78272563
0
199154...

result:

wrong answer 1st numbers differ - expected: '654245907', found: '263762899'

Test #7:

score: 0
Wrong Answer
time: 9ms
memory: 4100kb

input:

500 1000 1000
0001000110010010011110101001100111101101001010111110101100011110101111010110101000011010100011101101001111100111111000001101011011000110111010110001010000011001100000001011101111111100100111110110101101110101010000011001100110100101101000010000100110111110100000011011000101000101110001...

output:

148834607
286248539
369652647
74273540
397273375
790740328
861779773
0
466122875
10385149
0
297819548
924361861
840037698
463971419
427469802
661679983
491761537
82613009
143806923
295279298
362140955
466164709
65838118
980124190
108631175
524898836
0
502803994
524898836
0
44883507
126014055
7278136...

result:

wrong answer 1st numbers differ - expected: '539317615', found: '148834607'

Test #8:

score: 0
Wrong Answer
time: 91ms
memory: 8728kb

input:

1000 5000 1000
000011110101110100111100100001100001011110100101010000111011110001000101110101100010011000101000100111100101000001100010000100110101110110001111011000001001110000001001000110001001011000111101010011010011100110010001110011110101010001111000001101111100100100001000111100010010000011000...

output:

932724156
931440739
714097994
0
583003560
995187595
800635517
863719163
285509336
897798304
206792678
0
953369391
873614891
0
194143405
809338033
265071337
0
379316227
2341442
908966080
34633032
262005922
423852838
821517590
552261643
964655425
517460392
991934362
895806934
767392295
490659513
51239...

result:

wrong answer 1st numbers differ - expected: '621147360', found: '932724156'

Test #9:

score: 0
Wrong Answer
time: 86ms
memory: 8728kb

input:

1000 5000 1000
111111011011101011011100000000010111011000011000011101001101000001111001111101000010101010110010111001111110010001101011010101001001011110110000000001000110100001001100100100000011101110000110011000010000101110000100000101111001111110101000100011000100000110110010000010010111000101110...

output:

712028237
207463336
621410155
478268677
936991990
763521601
0
775297210
843397916
939295983
215153567
0
656319359
82680742
33660198
616685304
77310135
238491686
0
774329158
838392599
295360160
755661998
33326067
8817851
690243906
818119594
157394615
229014319
264723699
149781407
304978589
97355735
3...

result:

wrong answer 1st numbers differ - expected: '400451441', found: '712028237'

Test #10:

score: 0
Wrong Answer
time: 82ms
memory: 8956kb

input:

1000 5000 1000
001001001011101000010000010000111110001110100101100110101010010000000110010100101101000000001010110110010001000110110001000001001110010100110010101000000111101001011100111100011111001010101011010000011011010111011100110111110010110110100110000101101101000011100101000110011000100010101...

output:

661222365
682232555
281459458
103220531
914156715
56429626
0
0
841372429
0
0
718802899
548228635
133952726
882044283
686553455
8172328
615104611
972071329
0
526788312
0
296678095
756272502
757145936
693381194
580508674
817725914
688328957
0
419191285
698141613
85992357
370215
234599722
330857542
0
2...

result:

wrong answer 1st numbers differ - expected: '349645569', found: '661222365'