Submission #880264

# Submission time Handle Problem Language Result Execution time Memory
880264 2023-11-29T05:00:29 Z niter Snake Escaping (JOI18_snake_escaping) C++14
5 / 100
2000 ms 6780 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define entr cerr << endl;
#define spac cerr << ' ';
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x <<  " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) x.begin(), x.end()
#define unilize(x) x.resize(unique(BAE(x)) - x.begin())
#define unisort(x) sort(BAE(x)); unilize(x);
using namespace std;
typedef long long ll;

int n;
int a[2000000];

bool can(int x, string &s){
    loop(i,0,n){
        if(s[i] != '?'){
            bool tmp = (1 << i) & x;
            if(tmp != s[i] - '0') return false;
        }
    }
    return true;
}
int main(){
//    freopen("res.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
    int q;
    cin >> n >> q;
    int m = (1 << n);
    loop(i,0,m){
        char c;
        cin >> c;
        a[i] = c - '0';
    }
    loop(i,0,q){
        string s;
        cin >> s;
        reverse(BAE(s));
        int ans = 0;
        loop(i,0,m){
            if(can(i, s)) ans += a[i];
        }
        cout << ans << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 484 KB Output is correct
11 Execution timed out 2058 ms 6780 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 484 KB Output is correct
11 Execution timed out 2058 ms 6780 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 484 KB Output is correct
11 Execution timed out 2021 ms 5992 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 484 KB Output is correct
11 Execution timed out 2058 ms 6780 KB Time limit exceeded
12 Halted 0 ms 0 KB -