Submission #1117846

#TimeUsernameProblemLanguageResultExecution timeMemory
1117846vjudge1Kangaroo (CEOI16_kangaroo)C++11
0 / 100
1 ms336 KiB
//Desinged by AzeTurk810 Open source #include <bits/stdc++.h> using namespace std; # define ll long long # define ull unsigned long long # define hurryup ios_base::sync_with_stdio(false);cin.tie();cout.tie() # define pb push_back # define int int64_t int const LIMIT = 1e9; void print(vector<int>v) { for(int i=0;i<v.size();i++) { cout<<v[i]<< ' '; } cout<<endl; } /*int up=int(1e8) +20; vector<bool>is_prime2(up,false); vector<int>sieve (int n) { vector<bool>is_prime(up,true); vector<int>primes; ll k=0; primes.pb(2); primes.pb(3); primes.pb(5); is_prime2[2] = is_prime2[3] = is_prime2[5] = true; is_prime[0]=is_prime[1]=false; is_prime[4]= is_prime[6]=is_prime[10] =false; for(ll i=7;i<n;) { if(is_prime[i]) {primes.pb(i);is_prime2[i]=true;//if(i<20)cout<<i<<' '; for(ll j=(ll)i*i;j<n;j+=i) { is_prime[j]=false; } } if(k%2==0) { i+=4; } else i+=2; k++; } return primes; }*/ /*void solvemax(ll n,vector < int>primes,int up) { ll nc=n; ll sum=0,powr=0,sumc=0,powc=0,ans=1; int i=0; for(int i=0;primes[i]<=n && i<primes.size();i++) { //cout<<n<<endl; if(n<up) { if(is_prime2[n]) { //cout<<-1<<' '; ans*=n+1; n=1; } } if(n%primes[i]==0) { powc=0,powr=1,sum=0; while(n%primes[i]==0) { sum+=powr; powr*=primes[i]; n/=primes[i]; powc++; } sum+=powr; ans*=sum; } i++; } if(n>1) ans*=n+1; cout<<ans-nc<<endl; }*/ //vector<int>prm(1e6 + 1,0); /*void sqrtq(int limit) { //cout<<1<<endl; prm[1] = 1;ll last= 2; for(ll i=2;i<=limit;i++) { if(prm[i]==0) { prm [i] = last; last++; for(ll j=(ll)i*i;j<=limit;j+=i*i) {//return prm; prm[j]=-1; } } } }*/ signed main() { /*hurryup; ll t=1,n,m; cin>>t; vector<int>primes = sieve(up);//cout<<primes.size()<<endl; //if(is_prime[10]) //cout<<10<<endl; while(t--) { cin>>n; solvemax(n,primes,up); }*/ int t,n,a,ans = 0,cf,cs; cin>>n>>cs>>cf; vector<int>v(n); for(int i=0;i<n;i++) { v[i] = i + 1; } do{ //print(v); bool ok = 1; if(v[0] == cs && v[n - 1] == cf ) { for(int i=1;i< n - 1;i++) { if(v[i] > v[i-1] && v[i] >= v[i+ 1]) { t = 1; } else if(v[i] < v[i-1] && v[i] <= v[i+ 1]) t = 1; else ok = false;break; } if(ok){ ans++; //cout<<"ok"<<endl; //1000000007 } ans = ans % 1000000007; } } while(next_permutation(v.begin(),v.end())); // if(n == 2) // ans++; cout<<ans % 1000000007<<endl; }

Compilation message (stderr)

kangaroo.cpp: In function 'void print(std::vector<long int>)':
kangaroo.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
kangaroo.cpp: In function 'int main()':
kangaroo.cpp:146:17: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  146 |                 else
      |                 ^~~~
kangaroo.cpp:147:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  147 |                     ok = false;break;
      |                                ^~~~~
kangaroo.cpp:125:9: warning: variable 't' set but not used [-Wunused-but-set-variable]
  125 |     int t,n,a,ans = 0,cf,cs;
      |         ^
kangaroo.cpp:125:13: warning: unused variable 'a' [-Wunused-variable]
  125 |     int t,n,a,ans = 0,cf,cs;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...