답안 #256766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256766 2020-08-03T07:48:17 Z 문홍윤(#5040) Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 5496 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
#define lb(x, v) lower_bound(x.begin(), x.end(), v)
#define ub(x, v) upper_bound(x.begin(), x.end(), v)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2000000000000000000;
const LL mod1=1000000007;
const LL mod2=998244353;
const int inf=2000000000;

int n, q;
char str[1100000];
int arr[1100000];
char qu[30];

int main(){
    scanf("%d %d", &n, &q);
    scanf("%s", str);
    int len=strlen(str);
    for(int i=0; i<len; i++)arr[i]=(int)(str[i]-'0');
    for(int u=1; u<=q; u++){
        int ans=0;
        memset(qu, 0, sizeof qu);
        scanf("%s", qu+1);
        for(int i=0; i<(1<<n); i++){
            bool flg=true;
            for(int j=1; j<=n; j++){
                if(qu[j]=='?')continue;
                if(qu[j]=='0'&&(i&(1<<n-j)))flg=false;
                if(qu[j]=='1'&&(i&(1<<n-j))==0)flg=false;
            }
            if(flg)ans+=arr[i];
        }
        printf("%d\n", ans);
    }
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:40:40: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
                 if(qu[j]=='0'&&(i&(1<<n-j)))flg=false;
                                       ~^~
snake_escaping.cpp:41:40: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
                 if(qu[j]=='1'&&(i&(1<<n-j))==0)flg=false;
                                       ~^~
snake_escaping.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
snake_escaping.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str);
     ~~~~~^~~~~~~~~~~
snake_escaping.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", qu+1);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 16 ms 384 KB Output is correct
7 Correct 15 ms 288 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 19 ms 384 KB Output is correct
10 Correct 13 ms 276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 16 ms 384 KB Output is correct
7 Correct 15 ms 288 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 19 ms 384 KB Output is correct
10 Correct 13 ms 276 KB Output is correct
11 Execution timed out 2063 ms 1168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 16 ms 384 KB Output is correct
7 Correct 15 ms 288 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 19 ms 384 KB Output is correct
10 Correct 13 ms 276 KB Output is correct
11 Execution timed out 2063 ms 1168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 16 ms 384 KB Output is correct
7 Correct 15 ms 288 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 19 ms 384 KB Output is correct
10 Correct 13 ms 276 KB Output is correct
11 Execution timed out 2073 ms 5496 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 16 ms 384 KB Output is correct
7 Correct 15 ms 288 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 19 ms 384 KB Output is correct
10 Correct 13 ms 276 KB Output is correct
11 Execution timed out 2063 ms 1168 KB Time limit exceeded
12 Halted 0 ms 0 KB -