답안 #932455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932455 2024-02-23T12:24:46 Z Aiperiii 캥거루 (CEOI16_kangaroo) C++14
0 / 100
0 ms 348 KB
#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;
queue <vector <int> > q;
int ans=0,n,s,t;
void calc(){
    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();
            }
        }
    }
}
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    cin>>n>>s>>t;
    q.push({s});
    calc();
    q.push({t});
    calc();
    cout<<ans<<"\n";
}

Compilation message

kangaroo.cpp: In function 'void calc()':
kangaroo.cpp:14: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]
   14 |         if(v.size()==n){
      |            ~~~~~~~~^~~
kangaroo.cpp:20: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]
   20 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:25: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]
   25 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
kangaroo.cpp:34: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]
   34 |                 for(int i=0;i<v.size();i++){
      |                             ~^~~~~~~~~
kangaroo.cpp:39: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]
   39 |                     if(v.size()==n)q.push(v);
      |                        ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -