Submission #410216

# Submission time Handle Problem Language Result Execution time Memory
410216 2021-05-22T09:41:05 Z Blagojce Kangaroo (CEOI16_kangaroo) C++11
0 / 100
3 ms 332 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define st first
#define nd second
#define all(v) begin(v), end(v)
#define pq priority_queue

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int mxn = 2e5;


int n, f, s;
int p = 0;

int g(int a, int b, int pos, int side){
	int dir = ((n-(a+b))&1)^p;
	int ret = 0;
	if(side == 0){
		if(dir == 0){
			if(b == 0 && a == 1){
				return 0;
			}
			
			fr(ipos, 0, pos){
				ret += g(a-1, b, ipos, 0);
			}
		}
		else{
			if(b == 0 && a == 1){
				return 1;
			}
			
			fr(ipos, pos, a-1){
				ret += g(a-1, b, ipos, 0);
			}
			fr(ipos, 0, b){
				ret += g(a-1, b, ipos, 1);
			}
		}
	}
	else{
		if(dir == 1){
			if(a == 0 && b == 1){
				return 0;
			}
			
			fr(ipos, pos, b-1){
				ret += g(a, b-1, ipos, 1);
			}
		}
		else{
			if(a == 0 && b == 1){
				return 1;
			}
			
			fr(ipos, 0, pos){
				ret += g(a, b-1, ipos, 1);
			}
			fr(ipos, 0, a){
				ret += g(a, b-1, pos, 0);
			}
		}
	}
	return ret;
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	freopen("kangaroo.in", "r",stdin);
	freopen("kangaroo.out", "w",stdout);
	


	cin >> n >> s >> f;
	
	if(s > f) swap(s, f);
	--s, --f;
	
	
	int A = f;
	int B = n-A-1;
	int tot = g(A, B, s, 0);
	p = 1;
	tot += g(A, B, s, 0);
	cout<<tot<<endl;
	
	
	
}


Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:77:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |  freopen("kangaroo.in", "r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:78:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |  freopen("kangaroo.out", "w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -