답안 #1050366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050366 2024-08-09T08:57:01 Z vjudge1 Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 27396 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() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >>m >> q;
    n=pow(2, m);
    cin >>s;
    string s1;
    while(q--){
        cin >> s1;
        cout << b(0, 0, n, s1) << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 756 KB Output is correct
2 Correct 22 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 820 KB Output is correct
5 Correct 41 ms 1452 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1112 KB Output is correct
8 Correct 325 ms 656 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 19 ms 992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 756 KB Output is correct
2 Correct 22 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 820 KB Output is correct
5 Correct 41 ms 1452 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1112 KB Output is correct
8 Correct 325 ms 656 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 19 ms 992 KB Output is correct
11 Execution timed out 2031 ms 3532 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 756 KB Output is correct
2 Correct 22 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 820 KB Output is correct
5 Correct 41 ms 1452 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1112 KB Output is correct
8 Correct 325 ms 656 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 19 ms 992 KB Output is correct
11 Execution timed out 2031 ms 3532 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 756 KB Output is correct
2 Correct 22 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 820 KB Output is correct
5 Correct 41 ms 1452 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1112 KB Output is correct
8 Correct 325 ms 656 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 19 ms 992 KB Output is correct
11 Execution timed out 2028 ms 27396 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 756 KB Output is correct
2 Correct 22 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 5 ms 820 KB Output is correct
5 Correct 41 ms 1452 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1112 KB Output is correct
8 Correct 325 ms 656 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 19 ms 992 KB Output is correct
11 Execution timed out 2031 ms 3532 KB Time limit exceeded
12 Halted 0 ms 0 KB -