답안 #718927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718927 2023-04-05T07:26:33 Z ssense Snake Escaping (JOI18_snake_escaping) C++14
5 / 100
2000 ms 15100 KB
#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define pb push_back
#define sc second
#define fr first
#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);}int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}//mesanu

int n, q;
string s;

int answer_C(string t, int qm)
{
    int sum = 0;
    for(int i = 0; i < 1<<qm; i++)
    {
        int now = 0;
        int idx = 0;
        for(int j = 0; j < n; j++)
        {
            if(t[j] == '1')
            {
                now+=1<<j;
            }
            if(t[j] == '?')
            {
                if(i & (1<<idx))
                {
                    now+=1<<j;
                }
                idx++;
            }
        }
        sum+=(s[now]-'0');
    }
    return sum;
}

void solve()
{
    cin >> n >> q;
    cin >> s;
    while(q--)
    {
        string t;
        cin >> t;
        reverse(all(t));
        int qm = 0;
        for(int i = 0; i < t.size(); i++)
        {
            if(t[i] == '?'){qm++;}
        }
        cout << answer_C(t, qm) << endl;
    }
}

int32_t main(){
    startt
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
/*
3 5
12345678
000
0??
1?0
?11
???
*/

Compilation message

snake_escaping.cpp: In function 'void solve()':
snake_escaping.cpp:62:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i = 0; i < t.size(); i++)
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 324 KB Output is correct
8 Correct 34 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 324 KB Output is correct
8 Correct 34 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 2023 ms 15100 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 324 KB Output is correct
8 Correct 34 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 2023 ms 15100 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 324 KB Output is correct
8 Correct 34 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 2047 ms 3696 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 324 KB Output is correct
8 Correct 34 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 2023 ms 15100 KB Time limit exceeded
12 Halted 0 ms 0 KB -