답안 #932458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932458 2024-02-23T12:29:49 Z Aiperiii 캥거루 (CEOI16_kangaroo) C++14
6 / 100
484 ms 524288 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;
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

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);
      |                        ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 484 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -