Submission #67290

# Submission time Handle Problem Language Result Execution time Memory
67290 2018-08-13T19:38:02 Z ekrem DEL13 (info1cup18_del13) C++
0 / 100
500 ms 2252 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int t, n, q, m, b[N], a[N];
bool dp[3][N];

bool f(int sol, int ind){
	if(ind > m and sol == 0)
		return 1;
	if(sol > a[ind])
		return 0;
	int yeni = a[ind] - sol;
	bool don = 0;
	int md = a[ind]%2;
	if(a[ind] > 0 and !md)
		md = 2;
	if(sol == md)
		don |= f(0, ind + 1);
	// cout << a[ind] << " -> " << sol  << " = " << yeni << " , " << md<< endl;
	for(int i = 1; i <= 2; i++){
		if(yeni >= i and (yeni - i)%2 == 0)
			don |= f(i, ind + 1);
	}
	return don;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&t);
	while(t--){
		m = 0;
		scanf("%d %d",&n ,&q);
		for(int i = 1; i <= q; i++)
			scanf("%d", b + i);
		b[q + 1] = n + 1;
		for(int i = 1; i <= q + 1; i++)
			a[++m] = b[i] - b[i - 1] - 1;
		// for(int i = 1; i <= m; i++)cout << a[i] << " ";cout << endl;
		if(!f(0, 1))
			printf("-1\n");
		else
			printf("1\n");
	}
	return 0;
}

Compilation message

del13.cpp: In function 'int main()':
del13.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
del13.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n ,&q);
   ~~~~~^~~~~~~~~~~~~~~~
del13.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", b + i);
    ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Integer -1 violates the range [1, 9]
2 Incorrect 2 ms 356 KB Integer -1 violates the range [1, 8]
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Integer -1 violates the range [1, 9]
2 Incorrect 2 ms 356 KB Integer -1 violates the range [1, 8]
3 Incorrect 5 ms 520 KB Output isn't correct
4 Incorrect 6 ms 520 KB Integer -1 violates the range [1, 18]
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 664 KB Integer -1 violates the range [1, 28]
2 Incorrect 4 ms 664 KB Integer -1 violates the range [1, 5]
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Integer -1 violates the range [1, 9]
2 Incorrect 2 ms 356 KB Integer -1 violates the range [1, 8]
3 Incorrect 5 ms 520 KB Output isn't correct
4 Incorrect 6 ms 520 KB Integer -1 violates the range [1, 18]
5 Incorrect 2 ms 664 KB Output isn't correct
6 Incorrect 3 ms 664 KB Integer -1 violates the range [1, 100]
7 Incorrect 3 ms 664 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Integer -1 violates the range [1, 9]
2 Incorrect 2 ms 356 KB Integer -1 violates the range [1, 8]
3 Incorrect 5 ms 520 KB Output isn't correct
4 Incorrect 6 ms 520 KB Integer -1 violates the range [1, 18]
5 Incorrect 2 ms 664 KB Output isn't correct
6 Incorrect 3 ms 664 KB Integer -1 violates the range [1, 100]
7 Incorrect 3 ms 664 KB Output isn't correct
8 Execution timed out 1077 ms 832 KB Time limit exceeded
9 Execution timed out 1070 ms 844 KB Time limit exceeded
10 Execution timed out 1084 ms 1356 KB Time limit exceeded
11 Execution timed out 1068 ms 2252 KB Time limit exceeded