제출 #1310659

#제출 시각아이디문제언어결과실행 시간메모리
1310659lizi14동굴 (IOI13_cave)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include "cave.h"

using namespace std;
void exploreCave(int N) {
    vector<int>x(N,1),s(N,0),c(N,0);
    int an=0;
    int f=0;
    int h=0;
    int ans=0;
    
    while(h<N){
            
            int l=0,r=N;
            while(r-l>1){
               int mid=(l+r)/2;
               for(int i=l; i<mid; i++){
                   if(s[i]==0){
                       x[i]=1-x[i];
                   }
               }
                int k=tryCombination(x);
                for(int i=l; i<mid; i++){
                    if(s[i]==0){
                        x[i]=1-x[i];
                    }
                }
                if(k==-1 || k>h){
                    l=mid;
                    //ans=l;
                }
                else{
                    r=mid;
                }
               //else r=mid-1;
            }
            ans=l;
            x[ans]=0;
            if(tryCombination(x)==h)x[ans]=1;
            s[ans]=1;
            c[ans]=h;
            // an=a;
            // //x[ans]=1-x[ans];
            // s[ans]=1;
            // c[ans]=h;
            // for(int i=0; i<N; i++){
            //     if(s[i]==0){
            //         x[i]=0;
            //     }
            // }
            h++;
        }
        
        //h++;
        // else{
        //     for(int i=0; i<N; i++){
        //         if(s[i]==0){
        //             x[i]=1-x[i];
        //             //f=x[i];
        //         }
        //     }
        // }
        // for(int i=0; i<N; i++){
        //     cout<<x[i]<<" ";
        // }
        // cout<<endl;
        
        //x[a]=1-x[a];

    return answer(x, c);
}

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int>x(N,1),s(N,0),c(N,0);
      |     ^~~~~~
cave.cpp:6:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    5 | #include "cave.h"
  +++ |+#include <vector>
    6 | 
cave.cpp:9:12: error: expected primary-expression before 'int'
    9 |     vector<int>x(N,1),s(N,0),c(N,0);
      |            ^~~
cave.cpp:21:23: error: 's' was not declared in this scope
   21 |                    if(s[i]==0){
      |                       ^
cave.cpp:22:24: error: 'x' was not declared in this scope
   22 |                        x[i]=1-x[i];
      |                        ^
cave.cpp:25:38: error: 'x' was not declared in this scope
   25 |                 int k=tryCombination(x);
      |                                      ^
cave.cpp:27:24: error: 's' was not declared in this scope
   27 |                     if(s[i]==0){
      |                        ^
cave.cpp:41:13: error: 'x' was not declared in this scope
   41 |             x[ans]=0;
      |             ^
cave.cpp:43:13: error: 's' was not declared in this scope
   43 |             s[ans]=1;
      |             ^
cave.cpp:44:13: error: 'c' was not declared in this scope
   44 |             c[ans]=h;
      |             ^
cave.cpp:73:19: error: 'x' was not declared in this scope
   73 |     return answer(x, c);
      |                   ^
cave.cpp:73:22: error: 'c' was not declared in this scope
   73 |     return answer(x, c);
      |                      ^