# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66989 | 2018-08-13T07:28:04 Z | osmanorhan | Snake Escaping (JOI18_snake_escaping) | C++17 | 26 ms | 8312 KB |
#include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <cmath> #include <climits> #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <cassert> #include <vector> #define st first #define nd second #define mp make_pair #define pb push_back #define N 1600005 using namespace std; int n, m, a[(1<<20)+10], dp[N], prec[N], cvp[1000005], kaps[3000][200]; char c; pair < int , int > q[1000005]; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); for(int i = 0; i < 1594323; i++){ int x = i, crp = 1, ckr = -1, say = 0, bit = 0; while(x){ if(x%3 == 2){ ckr = crp; break; } bit += (1<<say)*(x%3); say++; crp *= 3; x /= 3; } if(ckr == -1) prec[i] = -bit; else prec[i] = ckr; } scanf("%d %d",&n ,&m); for(int i = 0; i < (1<<n); i++){ scanf(" %c",&c); a[i] = c - '0'; } for(int i = 1; i <= m; i++){ int say = 0, son = 0, crp = 1; long long bit = 0; for(int i = 1; i <= n; i++){ scanf(" %c" ,&c); bit *= 3; bit += (c == '?') ? 2 : c - '0'; } for(int say = 1; say <= 13; say++){ son += crp*(bit%3); crp *= 3; bit/=3; } // cout << bit << " , " << son << endl; q[i] = mp(bit, son); } for(int i = 0; i < 2187; i++) for(int j = 0; j < (1<<7); j++){ if(i == 0 and j == 0) kaps[i][j] = 1; else if(i%3 != 2 and i%3 != j%2) kaps[i][j] = 0; else kaps[i][j] = kaps[i/3][j/2]; } return 0; for(int i = 0; i < (1<<7); i++){ for(int j = 0; j < 1594323; j++){ if(prec[j] <= 0) dp[j] = a[i*(1<<13) - prec[j]]; else dp[j] = dp[j - prec[j]] + dp[j - prec[j]*2]; } for(int j = 1; j <= m; j++){ if(kaps[q[j].st ][i ] ){ cvp[j] += dp[q[j].nd]; } } } for(int i = 1; i <= m; i++) printf("%d\n",cvp[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |