Submission #1117700

#TimeUsernameProblemLanguageResultExecution timeMemory
1117700vjudge1Kangaroo (CEOI16_kangaroo)C++17
0 / 100
2 ms2640 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define run  ios_base::sync_with_stdio(false);cin.tie(0);
 
#define ll long long
#define pll pair<ll, ll>
#define ull unsigned ll
#define ld double
#define endl "\n"
#define pb push_back
#define fi first
#define se second
 
#define pi acos(-1)
#define N 100007
#define minimum -9223372036854775807
#define maximum -minimum
#define mod 1000000007
 
using namespace std;
using namespace __gnu_pbds;
template <class t>
using ordered_set=tree<t, null_type,less_equal<t>, rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll gcd(ll a, ll b)
{
	if(b==0)
		return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
	return a/gcd(a, b)*b;
}

bool isprime(ll n)
{
	if(n==1)
		return 0;
	for(ll i=2; i*i<=n; i++)
	{
		if(n%i==0)
			return 0;
	}
	return 1;
}

ll binpow(ll a, ll b)
{
    a%=mod;
    ll res=1;
    while(b>0)
	{
        if(b%2==1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}

ll n, m, cvb, res;
ll a[N];
bool used[N];
vector<ll>v[N];
priority_queue<pll, vector<pll>, greater<pll>>pq;

void bfs(ll node)
{
	pq.push({a[node], node});
	res=0;
	used[node]=1;
	while(!pq.empty())
	{
		ll f=pq.top().second;
		ll ff=pq.top().first;
		res+=ff;
//		cout<<"node: "<<f<<" ";
//		cout<<"res: "<<res<<endl;
		if(res>m)
		{
			return;
		}
		used[f]=1;
		pq.pop();
		for(ll i:v[f])
		{
			if(!used[i])
			{
				pq.push({a[i], i});
			}
		}
	}
}

int main()
{
    run;
    freopen("kangaroo.in", "r", stdin);
    freopen("kangaroo.out", "w", stdout);
    ll n, s, t, cvb=0;
    cin>>n>>s>>t;
    vector<ll>v;
    for(ll i=1; i<=n; i++)
    {
    	v.pb(i);
	}
	do
	{
		bool bul=1;
		if(v[0]!=s)
			bul=0;
		if(v[n-1]!=t)
			bul=0;
		if(abs(v[2]-v[1])>abs(v[1]-v[0]))
		{
			for(ll i=3; i<n; i++)
			{
				if(i%2==1)
				{
					if(abs(v[i]-v[i-1])>abs(v[i-1]-v[i-2]))
					{
						bul=0;
					}
				}
				else
				{
					if(abs(v[i]-v[i-1])<abs(v[i-1]-v[i-2]))
					{
						bul=0;
					}
				}
			}
		}
		else
		{
			for(ll i=3; i<n; i++)
			{
				if(i%2==1)
				{
					if(abs(v[i]-v[i-1])<abs(v[i-1]-v[i-2]))
					{
						bul=0;
					}
				}
				else
				{
					if(abs(v[i]-v[i-1])>abs(v[i-1]-v[i-2]))
					{
						bul=0;
					}
				}
			}
		}
		if(bul)
		{
			cvb++;/*
			for(ll i=0; i<n; i++)
			{
				cout<<v[i]<<" ";
			}
			cout<<endl;
			*/
		}
		cvb%=mod;
	}
	while(next_permutation(v.begin(), v.end()));
	cout<<cvb%mod<<endl;
}
// By Xanlar



// NUREDDIN <3 UZR ISTEYIREM PLS QEBUL ELE SENIN YERINDE OTURDUGUM UCUN

Compilation message (stderr)

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