Submission #405934

# Submission time Handle Problem Language Result Execution time Memory
405934 2021-05-17T05:17:17 Z AriaH Kangaroo (CEOI16_kangaroo) C++11
6 / 100
2000 ms 204 KB
/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define SZ(x)			    		(int)x.size()
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);

const int N = 10;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll inf = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll M)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); }

int n, s, f, seen[N];

ll tot;

void calc(int now, int prv)
{
	int full = 1;
	for(int i = 1; i <= n; i ++) full &= seen[i];
	if(full && now == f)
	{
		tot ++;
		if(tot == mod) tot = 0;
	}
	if(prv < now)
	{
		for(int j = 1; j < now; j ++)
		{
			if(seen[j]) continue;
			seen[j] = 1;
			calc(j, now);
			seen[j] = 0;
		}
	}
	else
	{
		for(int j = now + 1; j <= n; j ++)
		{
			if(seen[j]) continue;
			seen[j] = 1;
			calc(j, now);
			seen[j] = 0;
		}
	}
}

int main()
{
	scanf("%d%d%d", &n, &s, &f);
	seen[s] = 1;
	calc(s, 0);
	calc(s, n + 1);
	printf("%lld", tot);
    return 0;
}

/** test corner cases(n = 1?) watch for overflow or minus indices **/

Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |  scanf("%d%d%d", &n, &s, &f);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 2084 ms 204 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 2084 ms 204 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 2084 ms 204 KB Time limit exceeded
4 Halted 0 ms 0 KB -