Submission #1005053

# Submission time Handle Problem Language Result Execution time Memory
1005053 2024-06-22T06:45:45 Z erering Kangaroo (CEOI16_kangaroo) C++17
6 / 100
2000 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
#define int long long
const long long inf=1e18;
const int MOD=1e9+7;
const int N=41;
int n,cs,cf,ans=0;
void func(int i,set<int> s,bool flag){
    if(s.size()==n && i==cf){
        ans++;
        return;
    }
    if(flag){
        for(int j=i+1;j<=n;j++){
            if(!s.count(j)){
                s.insert(j);
                func(j,s,0);
                s.erase(j);
            }
        }
    }
    else{
        for(int j=i-1;j>0;j--){
            if(!s.count(j)){
                s.insert(j);
                func(j,s,1);
                s.erase(j);
            }
        }
    }
}
signed main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   cin>>n>>cs>>cf;
   set<int> s;
   s.insert(cs);
   func(cs,s,0);
   func(cs,s,1);
   cout<<ans;
}

Compilation message

kangaroo.cpp: In function 'void func(long long int, std::set<long long int>, bool)':
kangaroo.cpp:12:16: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   12 |     if(s.size()==n && i==cf){
      |        ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2086 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2086 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2086 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -