답안 #256719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256719 2020-08-03T07:12:57 Z 최은수(#5036) Snake Escaping (JOI18_snake_escaping) C++17
22 / 100
378 ms 32728 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
int sum[1600000];
int p3[20];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int l,q;
    cin>>l>>q;
    string s;
    cin>>s;
    p3[0]=1;
    for(int i=1;i<l+2;i++)
        p3[i]=p3[i-1]*3;
    vector<int>v;
    for(int i=0;i<1<<l;i++)
    {
        int id=0;
        for(int j=0;j<l;j++)
            id+=(i>>j&1)*p3[j];
        sum[id]=(char)s[i]-'0';
        v.eb(id);
    }
    for(int i=0;i<l;i++)
    {
        for(int k=0,m=v.size();k<m;k++)
        {
            int j=v[k];
            int cut=j%p3[i+1]/p3[i];
            sum[j+(2-cut)*p3[i]]+=sum[j];
            if(cut==1)
                v.eb(j+p3[i]);
        }
    }
    for(int i=0;i<q;i++)
    {
        string t;
        cin>>t;
        reverse(all(t));
        int id=0;
        for(int j=0;j<l;j++)
        {
            if(t[j]=='?')
                id+=p3[j]*2;
            else
                id+=((char)t[j]-'0')*p3[j];
        }
        cout<<sum[id]<<'\n';
    }
    cout.flush();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 239 ms 15820 KB Output is correct
12 Correct 241 ms 15356 KB Output is correct
13 Correct 213 ms 14580 KB Output is correct
14 Correct 217 ms 14712 KB Output is correct
15 Correct 263 ms 15904 KB Output is correct
16 Correct 362 ms 14840 KB Output is correct
17 Correct 224 ms 14840 KB Output is correct
18 Correct 181 ms 16760 KB Output is correct
19 Correct 179 ms 13688 KB Output is correct
20 Correct 234 ms 15316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 239 ms 15820 KB Output is correct
12 Correct 241 ms 15356 KB Output is correct
13 Correct 213 ms 14580 KB Output is correct
14 Correct 217 ms 14712 KB Output is correct
15 Correct 263 ms 15904 KB Output is correct
16 Correct 362 ms 14840 KB Output is correct
17 Correct 224 ms 14840 KB Output is correct
18 Correct 181 ms 16760 KB Output is correct
19 Correct 179 ms 13688 KB Output is correct
20 Correct 234 ms 15316 KB Output is correct
21 Correct 305 ms 30708 KB Output is correct
22 Correct 312 ms 30808 KB Output is correct
23 Correct 312 ms 29912 KB Output is correct
24 Correct 318 ms 29716 KB Output is correct
25 Correct 316 ms 31724 KB Output is correct
26 Correct 339 ms 30168 KB Output is correct
27 Correct 376 ms 30172 KB Output is correct
28 Correct 258 ms 32728 KB Output is correct
29 Correct 251 ms 28636 KB Output is correct
30 Correct 318 ms 30936 KB Output is correct
31 Correct 363 ms 30808 KB Output is correct
32 Correct 354 ms 30816 KB Output is correct
33 Correct 322 ms 29528 KB Output is correct
34 Correct 351 ms 29860 KB Output is correct
35 Correct 378 ms 30308 KB Output is correct
36 Correct 244 ms 28760 KB Output is correct
37 Correct 304 ms 30680 KB Output is correct
38 Correct 252 ms 28760 KB Output is correct
39 Correct 334 ms 30040 KB Output is correct
40 Correct 318 ms 29692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Runtime error 7 ms 5156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 239 ms 15820 KB Output is correct
12 Correct 241 ms 15356 KB Output is correct
13 Correct 213 ms 14580 KB Output is correct
14 Correct 217 ms 14712 KB Output is correct
15 Correct 263 ms 15904 KB Output is correct
16 Correct 362 ms 14840 KB Output is correct
17 Correct 224 ms 14840 KB Output is correct
18 Correct 181 ms 16760 KB Output is correct
19 Correct 179 ms 13688 KB Output is correct
20 Correct 234 ms 15316 KB Output is correct
21 Correct 305 ms 30708 KB Output is correct
22 Correct 312 ms 30808 KB Output is correct
23 Correct 312 ms 29912 KB Output is correct
24 Correct 318 ms 29716 KB Output is correct
25 Correct 316 ms 31724 KB Output is correct
26 Correct 339 ms 30168 KB Output is correct
27 Correct 376 ms 30172 KB Output is correct
28 Correct 258 ms 32728 KB Output is correct
29 Correct 251 ms 28636 KB Output is correct
30 Correct 318 ms 30936 KB Output is correct
31 Correct 363 ms 30808 KB Output is correct
32 Correct 354 ms 30816 KB Output is correct
33 Correct 322 ms 29528 KB Output is correct
34 Correct 351 ms 29860 KB Output is correct
35 Correct 378 ms 30308 KB Output is correct
36 Correct 244 ms 28760 KB Output is correct
37 Correct 304 ms 30680 KB Output is correct
38 Correct 252 ms 28760 KB Output is correct
39 Correct 334 ms 30040 KB Output is correct
40 Correct 318 ms 29692 KB Output is correct
41 Runtime error 7 ms 5156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -