답안 #680254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680254 2023-01-10T10:36:23 Z kakayoshi Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
2000 ms 42992 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;
unordered_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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3796 KB Output is correct
2 Correct 37 ms 3832 KB Output is correct
3 Correct 34 ms 3876 KB Output is correct
4 Correct 33 ms 3872 KB Output is correct
5 Correct 38 ms 3884 KB Output is correct
6 Correct 34 ms 3832 KB Output is correct
7 Correct 34 ms 3848 KB Output is correct
8 Correct 35 ms 3764 KB Output is correct
9 Correct 34 ms 3880 KB Output is correct
10 Correct 36 ms 3784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3796 KB Output is correct
2 Correct 37 ms 3832 KB Output is correct
3 Correct 34 ms 3876 KB Output is correct
4 Correct 33 ms 3872 KB Output is correct
5 Correct 38 ms 3884 KB Output is correct
6 Correct 34 ms 3832 KB Output is correct
7 Correct 34 ms 3848 KB Output is correct
8 Correct 35 ms 3764 KB Output is correct
9 Correct 34 ms 3880 KB Output is correct
10 Correct 36 ms 3784 KB Output is correct
11 Correct 233 ms 8752 KB Output is correct
12 Correct 299 ms 8468 KB Output is correct
13 Correct 268 ms 7660 KB Output is correct
14 Correct 240 ms 7756 KB Output is correct
15 Correct 267 ms 8740 KB Output is correct
16 Correct 265 ms 7928 KB Output is correct
17 Correct 278 ms 7840 KB Output is correct
18 Correct 190 ms 9732 KB Output is correct
19 Correct 183 ms 6784 KB Output is correct
20 Correct 249 ms 8480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3796 KB Output is correct
2 Correct 37 ms 3832 KB Output is correct
3 Correct 34 ms 3876 KB Output is correct
4 Correct 33 ms 3872 KB Output is correct
5 Correct 38 ms 3884 KB Output is correct
6 Correct 34 ms 3832 KB Output is correct
7 Correct 34 ms 3848 KB Output is correct
8 Correct 35 ms 3764 KB Output is correct
9 Correct 34 ms 3880 KB Output is correct
10 Correct 36 ms 3784 KB Output is correct
11 Correct 233 ms 8752 KB Output is correct
12 Correct 299 ms 8468 KB Output is correct
13 Correct 268 ms 7660 KB Output is correct
14 Correct 240 ms 7756 KB Output is correct
15 Correct 267 ms 8740 KB Output is correct
16 Correct 265 ms 7928 KB Output is correct
17 Correct 278 ms 7840 KB Output is correct
18 Correct 190 ms 9732 KB Output is correct
19 Correct 183 ms 6784 KB Output is correct
20 Correct 249 ms 8480 KB Output is correct
21 Execution timed out 2089 ms 42992 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3796 KB Output is correct
2 Correct 37 ms 3832 KB Output is correct
3 Correct 34 ms 3876 KB Output is correct
4 Correct 33 ms 3872 KB Output is correct
5 Correct 38 ms 3884 KB Output is correct
6 Correct 34 ms 3832 KB Output is correct
7 Correct 34 ms 3848 KB Output is correct
8 Correct 35 ms 3764 KB Output is correct
9 Correct 34 ms 3880 KB Output is correct
10 Correct 36 ms 3784 KB Output is correct
11 Runtime error 6 ms 6960 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3796 KB Output is correct
2 Correct 37 ms 3832 KB Output is correct
3 Correct 34 ms 3876 KB Output is correct
4 Correct 33 ms 3872 KB Output is correct
5 Correct 38 ms 3884 KB Output is correct
6 Correct 34 ms 3832 KB Output is correct
7 Correct 34 ms 3848 KB Output is correct
8 Correct 35 ms 3764 KB Output is correct
9 Correct 34 ms 3880 KB Output is correct
10 Correct 36 ms 3784 KB Output is correct
11 Correct 233 ms 8752 KB Output is correct
12 Correct 299 ms 8468 KB Output is correct
13 Correct 268 ms 7660 KB Output is correct
14 Correct 240 ms 7756 KB Output is correct
15 Correct 267 ms 8740 KB Output is correct
16 Correct 265 ms 7928 KB Output is correct
17 Correct 278 ms 7840 KB Output is correct
18 Correct 190 ms 9732 KB Output is correct
19 Correct 183 ms 6784 KB Output is correct
20 Correct 249 ms 8480 KB Output is correct
21 Execution timed out 2089 ms 42992 KB Time limit exceeded
22 Halted 0 ms 0 KB -