답안 #1005053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005053 2024-06-22T06:45:45 Z erering 캥거루 (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){
      |        ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -