Submission #742480

# Submission time Handle Problem Language Result Execution time Memory
742480 2023-05-16T09:59:02 Z salmon Tortoise (CEOI21_tortoise) C++14
0 / 100
2167 ms 276 KB
#include <bits/stdc++.h>
using namespace std;
int lst[25];
int N;

int recurse(int i, int t,bitset<25> v, bool hold){
	if(t == N * 2 - 1){
		return 0;
	}
	
	int ans = 0;
	
	if(!hold && v[i]){
		v[i] = false;
		hold = true;
	}
	
	if(hold && lst[i] == -1){
		hold = false;
	}
	
	if(t % 2 == 0 && lst[t/2] != -1 && v[i]){
		ans += 1;
		v[i] = false;
	}
	
	if(i == 0){
		return ans + recurse(i + 1, t + 1, v, hold);
	}
	else if(i == N - 1){
		return ans + recurse(i - 1, t + 1, v, hold);
	}
	else{
		return ans + min(recurse(i + 1, t + 1,v,hold),recurse(i - 1, t + 1, v, hold));
	}
}

int main(){
	
	scanf(" %d",&N);
	
	deque<int> v;
	
	bitset<25> b;
	
	for(int i = 0; i < N; i++){
		scanf(" %d",&lst[i]);
		if(lst[i] == 1){
			b.set(i,true);
		}
	}
	
	printf("%d",recurse(0,0,b,false));
}

Compilation message

tortoise.cpp: In function 'int main()':
tortoise.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf(" %d",&N);
      |  ~~~~~^~~~~~~~~~
tortoise.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf(" %d",&lst[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2167 ms 276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2167 ms 276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2167 ms 276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2167 ms 276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2167 ms 276 KB Output isn't correct
2 Halted 0 ms 0 KB -