Submission #1288018

#TimeUsernameProblemLanguageResultExecution timeMemory
1288018SmuggingSpunKangaroo (CEOI16_kangaroo)C++20
6 / 100
1 ms572 KiB
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
int n, cs, cf;
namespace sub1{
	void solve(){
		int ans = 0;
		vector<int>p(n);
		iota(p.begin(), p.end(), 1);
		do{
			if(cs == p[0] && cf == p[n - 1]){
				bool f1 = true, f2 = true;
				for(int i = 1; i < n; i++){
					if(((i & 1) && p[i] > p[i - 1]) || ((~i & 1) && p[i] < p[i - 1])){
						f1 = false;
					}
					if(((i & 1) && p[i] < p[i - 1]) || ((~i & 1) && p[i] > p[i - 1])){
						f2 = false;
					}
				}
				if(f1 || f2){
					ans++;
				}
			}
		} while(next_permutation(p.begin(), p.end()));
		cout << ans;
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	cin >> n >> cs >> cf;
	if(n <= 8){
		sub1::solve();
	}
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:32:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...