Submission #1050155

# Submission time Handle Problem Language Result Execution time Memory
1050155 2024-08-09T07:45:18 Z vjudge1 Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 27380 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
string s;
int n, m, q;
map<string, map<int, long long>> mp;
long long b(int p, int l, int r, string s1){
    if(mp[&s[p]][l]==0){
        while(s1[p]!='?'&&p<m){
            if(s1[p]=='0'){
                r=(l+r)/2;
                }else{
                l=(l+r)/2;
            }
            p++;
        }
        if(p==m){
            return s[l]-'0';
        }else{
            long long cnt=b(p+1, l, (r+l)/2, s1)+b(p+1, (r+l)/2, r, s1);
            if(cnt==0){
                mp[&s1[p]][l]=-1;
            }else{
                mp[&s1[p]][l]=cnt;
            }
            return cnt;
        }
    }else{
        return max(mp[&s[p]][l], 0ll);
    }
}
int main() {
    cin >>m >> q;
    n=pow(2, m);
    cin >>s;
    string s1;
    while(q--){
        cin >> s1;
        cout << b(0, 0, n, s1) << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 20 ms 964 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 28 ms 1340 KB Output is correct
6 Correct 9 ms 1112 KB Output is correct
7 Correct 8 ms 1208 KB Output is correct
8 Correct 257 ms 640 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 25 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 20 ms 964 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 28 ms 1340 KB Output is correct
6 Correct 9 ms 1112 KB Output is correct
7 Correct 8 ms 1208 KB Output is correct
8 Correct 257 ms 640 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 25 ms 896 KB Output is correct
11 Execution timed out 2019 ms 3404 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 20 ms 964 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 28 ms 1340 KB Output is correct
6 Correct 9 ms 1112 KB Output is correct
7 Correct 8 ms 1208 KB Output is correct
8 Correct 257 ms 640 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 25 ms 896 KB Output is correct
11 Execution timed out 2019 ms 3404 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 20 ms 964 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 28 ms 1340 KB Output is correct
6 Correct 9 ms 1112 KB Output is correct
7 Correct 8 ms 1208 KB Output is correct
8 Correct 257 ms 640 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 25 ms 896 KB Output is correct
11 Execution timed out 2047 ms 27380 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 604 KB Output is correct
2 Correct 20 ms 964 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 28 ms 1340 KB Output is correct
6 Correct 9 ms 1112 KB Output is correct
7 Correct 8 ms 1208 KB Output is correct
8 Correct 257 ms 640 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 25 ms 896 KB Output is correct
11 Execution timed out 2019 ms 3404 KB Time limit exceeded
12 Halted 0 ms 0 KB -