Submission #521885

# Submission time Handle Problem Language Result Execution time Memory
521885 2022-02-03T11:01:38 Z Monarchuwu Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 3736 KB
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

const int N = 2e6 + 4;
int l, q;
string s;

bool check(int mask, string s) {
    for (int i = 0; i < l; ++i) {
        char c = s[s.size() - 1 - i];
        if (c != '?') {
            if (c == '1') {
                if (!(mask >> i & 1)) return false;
            }
            else {
                if (mask >> i & 1) return false;
            }
        }
    }
    return true;
}

int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> l >> q >> s;
    while (q--) {
        string t; cin >> t;
        int sum(0);

        for (int i = 0; i < s.size(); ++i)
            if (check(i, t)) sum += s[i] ^ 48;
        cout << sum << '\n';
    }
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int i = 0; i < s.size(); ++i)
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 23 ms 316 KB Output is correct
2 Correct 22 ms 312 KB Output is correct
3 Correct 18 ms 324 KB Output is correct
4 Correct 22 ms 324 KB Output is correct
5 Correct 19 ms 204 KB Output is correct
6 Correct 20 ms 324 KB Output is correct
7 Correct 19 ms 320 KB Output is correct
8 Correct 23 ms 332 KB Output is correct
9 Correct 17 ms 320 KB Output is correct
10 Correct 18 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 316 KB Output is correct
2 Correct 22 ms 312 KB Output is correct
3 Correct 18 ms 324 KB Output is correct
4 Correct 22 ms 324 KB Output is correct
5 Correct 19 ms 204 KB Output is correct
6 Correct 20 ms 324 KB Output is correct
7 Correct 19 ms 320 KB Output is correct
8 Correct 23 ms 332 KB Output is correct
9 Correct 17 ms 320 KB Output is correct
10 Correct 18 ms 324 KB Output is correct
11 Execution timed out 2067 ms 2308 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 316 KB Output is correct
2 Correct 22 ms 312 KB Output is correct
3 Correct 18 ms 324 KB Output is correct
4 Correct 22 ms 324 KB Output is correct
5 Correct 19 ms 204 KB Output is correct
6 Correct 20 ms 324 KB Output is correct
7 Correct 19 ms 320 KB Output is correct
8 Correct 23 ms 332 KB Output is correct
9 Correct 17 ms 320 KB Output is correct
10 Correct 18 ms 324 KB Output is correct
11 Execution timed out 2067 ms 2308 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 316 KB Output is correct
2 Correct 22 ms 312 KB Output is correct
3 Correct 18 ms 324 KB Output is correct
4 Correct 22 ms 324 KB Output is correct
5 Correct 19 ms 204 KB Output is correct
6 Correct 20 ms 324 KB Output is correct
7 Correct 19 ms 320 KB Output is correct
8 Correct 23 ms 332 KB Output is correct
9 Correct 17 ms 320 KB Output is correct
10 Correct 18 ms 324 KB Output is correct
11 Execution timed out 2025 ms 3736 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 316 KB Output is correct
2 Correct 22 ms 312 KB Output is correct
3 Correct 18 ms 324 KB Output is correct
4 Correct 22 ms 324 KB Output is correct
5 Correct 19 ms 204 KB Output is correct
6 Correct 20 ms 324 KB Output is correct
7 Correct 19 ms 320 KB Output is correct
8 Correct 23 ms 332 KB Output is correct
9 Correct 17 ms 320 KB Output is correct
10 Correct 18 ms 324 KB Output is correct
11 Execution timed out 2067 ms 2308 KB Time limit exceeded
12 Halted 0 ms 0 KB -