제출 #784717

#제출 시각아이디문제언어결과실행 시간메모리
784717angels동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#include "cave.h"

using namespace std;
bool visited[5001];
int R[5001], D[5001];

void change(int start, int end)
{
    for(int i=start; i<=end; i++)
    {
        if(!visited[i])
        {
            if(R[i]==0)
                R[i]=1;
            else
                R[i]=0;
        }
    }
}
void exploreCave(int N)
{
    int n=N;
    for(int i=0; i<n; i++)
    {
        int x=tryCombination(n, R);
        int kiki, kiki1;
        if(x>i || x==-1)
            kiki=0;
        else 
            kiki=1;
        int start=0, end=n-1;
        while(start<end)
        {
            int mid=(start+end)/2;
            change(start, mid);
            x=tryCombination(n, R);
            if(x>i || x==-1)
                kiki1=0;
            else
                kiki1=1;
            change(start, mid);
            if(kiki==kiki1)
                start=mid+1;
            else
                end=mid;
        }
        R[start]=kiki;
        D[start]=i;
        visited[start]=true;
    }
    answer(N, R, D);
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:34:30: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   34 |         int x=tryCombination(n, R);
      |                              ^
      |                              |
      |                              int
cave.cpp:34:34: error: too many arguments to function 'int tryCombination(int*)'
   34 |         int x=tryCombination(n, R);
      |                                  ^
In file included from cave.cpp:10:
cave.h:8:5: note: declared here
    8 | int tryCombination(int S[]);
      |     ^~~~~~~~~~~~~~
cave.cpp:45:30: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   45 |             x=tryCombination(n, R);
      |                              ^
      |                              |
      |                              int
cave.cpp:45:34: error: too many arguments to function 'int tryCombination(int*)'
   45 |             x=tryCombination(n, R);
      |                                  ^
In file included from cave.cpp:10:
cave.h:8:5: note: declared here
    8 | int tryCombination(int S[]);
      |     ^~~~~~~~~~~~~~
cave.cpp:60:12: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   60 |     answer(N, R, D);
      |            ^
      |            |
      |            int
cave.cpp:60:19: error: too many arguments to function 'void answer(int*, int*)'
   60 |     answer(N, R, D);
      |                   ^
In file included from cave.cpp:10:
cave.h:9:6: note: declared here
    9 | void answer(int S[], int D[]);
      |      ^~~~~~