QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#681842#6237. 寻宝游戏propane0 0ms0kbC++201.3kb2024-10-27 12:23:372024-10-27 12:23:38

Judging History

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

  • [2024-10-27 12:23:38]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-10-27 12:23:37]
  • 提交

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(n);
    for(int i = 0; i < n; 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;
        }
    }
    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 cout << (val[id[mx]] - val[id[mn]] + mod) % mod << '\n';
    }

}

詳細信息


Pretests


Final Tests

Test #1:

score: 0
Runtime Error

input:

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

output:


result:


Test #2:

score: 0
Runtime Error

input:

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

output:


result:


Test #3:

score: 0
Runtime Error

input:

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

output:


result:


Test #4:

score: 0
Runtime Error

input:

500 1000 1000
0011010011000100101111101101101101011100000001011001010101111101011100101111100001100000101101010101100100011001011111110011101110010111111100100000001111111100000110000110101010001101000101010000010100111101111011010110101101000110000111010011011001111000100001011010100100011000110110...

output:


result:


Test #5:

score: 0
Runtime Error

input:

500 1000 1000
0001001101001100001110001100001010101111101011011011011100101001010101001111101111100101110011011010111010110100101010111100101110011101000100010000001111111010101110011001011111011110111111100011001010111100101110101101000100110011100101101101010011101111010001000111101111000111000110...

output:


result:


Test #6:

score: 0
Runtime Error

input:

500 1000 1000
0000011100101100010011000011111000111000011010110101100110100011100010000111101100111110110101101110000001101110100101110000011101011000011000110001010110011100101100010100001000011100101100001101110111111100110101000010001110110001011011110110101110101001011111000111000101010010101001...

output:


result:


Test #7:

score: 0
Runtime Error

input:

500 1000 1000
0001000110010010011110101001100111101101001010111110101100011110101111010110101000011010100011101101001111100111111000001101011011000110111010110001010000011001100000001011101111111100100111110110101101110101010000011001100110100101101000010000100110111110100000011011000101000101110001...

output:


result:


Test #8:

score: 0
Runtime Error

input:

1000 5000 1000
000011110101110100111100100001100001011110100101010000111011110001000101110101100010011000101000100111100101000001100010000100110101110110001111011000001001110000001001000110001001011000111101010011010011100110010001110011110101010001111000001101111100100100001000111100010010000011000...

output:


result:


Test #9:

score: 0
Runtime Error

input:

1000 5000 1000
111111011011101011011100000000010111011000011000011101001101000001111001111101000010101010110010111001111110010001101011010101001001011110110000000001000110100001001100100100000011101110000110011000010000101110000100000101111001111110101000100011000100000110110010000010010111000101110...

output:


result:


Test #10:

score: 0
Runtime Error

input:

1000 5000 1000
001001001011101000010000010000111110001110100101100110101010010000000110010100101101000000001010110110010001000110110001000001001110010100110010101000000111101001011100111100011111001010101011010000011011010111011100110111110010110110100110000101101101000011100101000110011000100010101...

output:


result: