Submission #158868

# Submission time Handle Problem Language Result Execution time Memory
158868 2019-10-19T08:53:56 Z ioane Snake Escaping (JOI18_snake_escaping) C++14
0 / 100
4 ms 1016 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define LL int
#define MP make_pair
#define PB push_back
#define I insert

const LL N = 1600000;

using namespace std;

LL n, m, i, j, k, l, r, t, x, y;
LL a[N], dp[N], x3[20];
char c;

int main(){
	x3[0] = 1;
	for ( i = 1; i < 20; ++i ){
		x3[i] = x3[i-1] * 3;
	}
	
	cin >> n >> m;
	for ( i = 0; i < (1<<n); ++i ){
		scanf("%c",&c);
		a[i] = c - '0';
	}
	k = min(n,13);
	for ( i = 0; i < x3[k]; ++i ){
		t = i;
		l = 0;
		for ( j = 0; j < k; ++j ){
			r = t % 3;
			if ( r == 2 ){
				dp[i] = dp[i - x3[j]] + dp[i - 2*x3[j]];
				l = -100;
				break;
			}
			l += (1<<(j)) * r;
			t /= 3;
		}
		if ( l >= 0 ){
			dp[i] = a[l];
		}
		//cout << i << " " << dp[i] << "  " << l << endl;
	}
	
	while ( m-- ){
		t = 0;
		for ( i = 0; i < k; ++i ){
			scanf("%c",&c);
			t *= 3;
			if ( c == '?' ) t += 2;
			else t += c - '0';
		}
		
		cout << dp[t] << endl;
	}
	
	return 0;
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%c",&c);
   ~~~~~^~~~~~~~~
snake_escaping.cpp:51:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c",&c);
    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -