Submission #932458

#TimeUsernameProblemLanguageResultExecution timeMemory
932458AiperiiiKangaroo (CEOI16_kangaroo)C++14
6 / 100
484 ms524288 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb push_back using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,s,t; cin>>n>>s>>t; queue <vector <int> > q; q.push({s}); int ans=0; while(!q.empty()){ vector <int> v=q.front(); q.pop(); if(v.size()==n){ ans++;continue; } if(v.size()%2==0){ for(int j=v.back();j>=1;j--){ bool ok=1; for(int i=0;i<v.size();i++){ if(j==v[i])ok=0; } v.pb(j); if(ok){ if(v.size()==n)q.push(v); else if(j!=t)q.push(v); } v.pop_back(); } } else{ for(int j=v.back();j<=n;j++){ bool ok=1; for(int i=0;i<v.size();i++){ if(j==v[i])ok=0; } v.pb(j); if(ok){ if(v.size()==n)q.push(v); else if(j!=t)q.push(v); } v.pop_back(); } } } q.push({s}); while(!q.empty()){ vector <int> v=q.front(); q.pop(); if(v.size()==n){ ans++;continue; } if(v.size()%2==1){ for(int j=v.back();j>=1;j--){ bool ok=1; for(int i=0;i<v.size();i++){ if(j==v[i])ok=0; } v.pb(j); if(ok){ if(v.size()==n)q.push(v); else if(j!=t)q.push(v); } v.pop_back(); } } else{ for(int j=v.back();j<=n;j++){ bool ok=1; for(int i=0;i<v.size();i++){ if(j==v[i])ok=0; } v.pb(j); if(ok){ if(v.size()==n)q.push(v); else if(j!=t)q.push(v); } v.pop_back(); } } } cout<<ans<<"\n"; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:19:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |         if(v.size()==n){
      |            ~~~~~~~~^~~
kangaroo.cpp:26:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:31:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   31 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
kangaroo.cpp:40:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:45:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
kangaroo.cpp:57:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   57 |         if(v.size()==n){
      |            ~~~~~~~~^~~
kangaroo.cpp:64:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:69:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   69 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
kangaroo.cpp:78:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:83:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   83 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...