Submission #680246

# Submission time Handle Problem Language Result Execution time Memory
680246 2023-01-10T10:31:28 Z vjudge1 Snake Escaping (JOI18_snake_escaping) C++17
12 / 100
2000 ms 39400 KB
#include <bits/stdc++.h>
using namespace std;
#define forw(i,a,b) for(ll i=a;i<=b;i++)
#define forb(i,a,b) for(int i=a;i>=b;i--)
#define pu push
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(),a.end()
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,pair<ll,ll> > plll;
const ll maxN=(1<<14)+5;
const ll oo=1e18;
map<ll,ll> save[maxN];
ll n,q;
void solve()
{
    cin>>n>>q;
    forw(mask1,0,(1<<n)-1)
    {
        char c; cin>>c;
        forw(mask2,0,(1<<n)-1)
        {
            ll tmp=mask1&mask2;
            ll new_mask=mask1-tmp;
            save[mask2][new_mask]+=(c-'0');
            //if (mask2==6 && new_mask==0) cout<<mask1<<" "<<(c-'0')<<endl;
        }
    }
    while (q--)
    {
        string s; cin>>s; reverse(all(s));
        ll mask1=0;
        ll mask2=0;
        forw(i,0,n-1)
        if (s[i]=='?') mask2+=(1LL<<i);
        else
            mask1+=(1LL<<i)*(s[i]=='1');
        if (save[mask2].find(mask1)!=save[mask2].end())
            cout<<save[mask2][mask1]<<"\n";
        else
            cout<<0<<"\n";
    }
    return;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("c.inp","r",stdin);
    //freopen("c.out","w",stdout);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4684 KB Output is correct
2 Correct 51 ms 4768 KB Output is correct
3 Correct 51 ms 4688 KB Output is correct
4 Correct 52 ms 4732 KB Output is correct
5 Correct 54 ms 4760 KB Output is correct
6 Correct 51 ms 4772 KB Output is correct
7 Correct 52 ms 4740 KB Output is correct
8 Correct 50 ms 4736 KB Output is correct
9 Correct 52 ms 4680 KB Output is correct
10 Correct 52 ms 4680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4684 KB Output is correct
2 Correct 51 ms 4768 KB Output is correct
3 Correct 51 ms 4688 KB Output is correct
4 Correct 52 ms 4732 KB Output is correct
5 Correct 54 ms 4760 KB Output is correct
6 Correct 51 ms 4772 KB Output is correct
7 Correct 52 ms 4740 KB Output is correct
8 Correct 50 ms 4736 KB Output is correct
9 Correct 52 ms 4680 KB Output is correct
10 Correct 52 ms 4680 KB Output is correct
11 Correct 310 ms 18760 KB Output is correct
12 Correct 304 ms 18440 KB Output is correct
13 Correct 383 ms 17740 KB Output is correct
14 Correct 381 ms 17796 KB Output is correct
15 Correct 312 ms 18764 KB Output is correct
16 Correct 393 ms 18008 KB Output is correct
17 Correct 400 ms 17952 KB Output is correct
18 Correct 208 ms 19776 KB Output is correct
19 Correct 299 ms 16864 KB Output is correct
20 Correct 366 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4684 KB Output is correct
2 Correct 51 ms 4768 KB Output is correct
3 Correct 51 ms 4688 KB Output is correct
4 Correct 52 ms 4732 KB Output is correct
5 Correct 54 ms 4760 KB Output is correct
6 Correct 51 ms 4772 KB Output is correct
7 Correct 52 ms 4740 KB Output is correct
8 Correct 50 ms 4736 KB Output is correct
9 Correct 52 ms 4680 KB Output is correct
10 Correct 52 ms 4680 KB Output is correct
11 Correct 310 ms 18760 KB Output is correct
12 Correct 304 ms 18440 KB Output is correct
13 Correct 383 ms 17740 KB Output is correct
14 Correct 381 ms 17796 KB Output is correct
15 Correct 312 ms 18764 KB Output is correct
16 Correct 393 ms 18008 KB Output is correct
17 Correct 400 ms 17952 KB Output is correct
18 Correct 208 ms 19776 KB Output is correct
19 Correct 299 ms 16864 KB Output is correct
20 Correct 366 ms 18404 KB Output is correct
21 Execution timed out 2084 ms 39400 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4684 KB Output is correct
2 Correct 51 ms 4768 KB Output is correct
3 Correct 51 ms 4688 KB Output is correct
4 Correct 52 ms 4732 KB Output is correct
5 Correct 54 ms 4760 KB Output is correct
6 Correct 51 ms 4772 KB Output is correct
7 Correct 52 ms 4740 KB Output is correct
8 Correct 50 ms 4736 KB Output is correct
9 Correct 52 ms 4680 KB Output is correct
10 Correct 52 ms 4680 KB Output is correct
11 Runtime error 4 ms 4052 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4684 KB Output is correct
2 Correct 51 ms 4768 KB Output is correct
3 Correct 51 ms 4688 KB Output is correct
4 Correct 52 ms 4732 KB Output is correct
5 Correct 54 ms 4760 KB Output is correct
6 Correct 51 ms 4772 KB Output is correct
7 Correct 52 ms 4740 KB Output is correct
8 Correct 50 ms 4736 KB Output is correct
9 Correct 52 ms 4680 KB Output is correct
10 Correct 52 ms 4680 KB Output is correct
11 Correct 310 ms 18760 KB Output is correct
12 Correct 304 ms 18440 KB Output is correct
13 Correct 383 ms 17740 KB Output is correct
14 Correct 381 ms 17796 KB Output is correct
15 Correct 312 ms 18764 KB Output is correct
16 Correct 393 ms 18008 KB Output is correct
17 Correct 400 ms 17952 KB Output is correct
18 Correct 208 ms 19776 KB Output is correct
19 Correct 299 ms 16864 KB Output is correct
20 Correct 366 ms 18404 KB Output is correct
21 Execution timed out 2084 ms 39400 KB Time limit exceeded
22 Halted 0 ms 0 KB -