제출 #870851

#제출 시각아이디문제언어결과실행 시간메모리
870851HuyQuang_re_Zero동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#include "cave.h"
using namespace std;
/*
struct Interactive
{
    int n=4,True[4]={ 1,1,1,0 },Door[4]={ 3,1,0,2 },d[5002];
    int Try(int a[])
    {
        for(int i=0;i<n;i++)
            if(a[i]==True[i]) d[Door[i]]=0; else d[Door[i]]=1;
        for(int i=0;i<n;i++)
            if(d[i]==1) return i;
        return -1;
    }
} IR;

int n,a[5002],b[5002],door[5002],i,j;
int tryCombination(int a[])
{
    for(int i=0;i<n;i++) cout<<a[i]<<" ";
    cout<<'\n';
    return IR.Try(a);
}
void answer(int a[],int b[])
{
    for(int i=0;i<n;i++) cout<<a[i]<<" ";
    cout<<'\n';
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
}*/

int check_close(int u,int cnt,int ch)
{
    for(int i=0;i<n;i++)
        if(a[i+1]>-1) b[i]=a[i+1];
        else if(cnt>0)
        {
            cnt--;
            b[i]=ch;
        }
        else b[i]=0;
    return tryCombination(b)+1==u;
}
void Work()
{
    memset(a,-1,sizeof(a));
    for(i=1;i<=n;i++)
    {
        int k=check_close(i,n-i+1,0),l=1,r=n-i+1;
        while(l<r)
        {
            int mid=(l+r)>>1;
            if(check_close(i,mid,1)!=k) r=mid; else l=mid+1;
        }
        for(j=1;j<=n;j++)
            if(a[j]==-1)
            {
                l--;
                if(l==0) break;
            }
        a[j]=k;
        door[j-1]=i-1;
    }
    for(i=0;i<n;i++) b[i]=a[i+1];
    answer(b,door);
}
void exploreCave(int _n)
{
    n=_n;
    Work();
}
/*
int main()
{
    freopen("cave.inp","r",stdin);
    freopen("cave.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    exploreCave(n);
}
*/

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

cave.cpp: In function 'int check_close(int, int, int)':
cave.cpp:47:19: error: 'n' was not declared in this scope
   47 |     for(int i=0;i<n;i++)
      |                   ^
cave.cpp:48:12: error: 'a' was not declared in this scope
   48 |         if(a[i+1]>-1) b[i]=a[i+1];
      |            ^
cave.cpp:48:23: error: 'b' was not declared in this scope
   48 |         if(a[i+1]>-1) b[i]=a[i+1];
      |                       ^
cave.cpp:52:13: error: 'b' was not declared in this scope
   52 |             b[i]=ch;
      |             ^
cave.cpp:54:14: error: 'b' was not declared in this scope
   54 |         else b[i]=0;
      |              ^
cave.cpp:55:27: error: 'b' was not declared in this scope
   55 |     return tryCombination(b)+1==u;
      |                           ^
cave.cpp: In function 'void Work()':
cave.cpp:59:12: error: 'a' was not declared in this scope
   59 |     memset(a,-1,sizeof(a));
      |            ^
cave.cpp:60:9: error: 'i' was not declared in this scope; did you mean 'pi'?
   60 |     for(i=1;i<=n;i++)
      |         ^
      |         pi
cave.cpp:60:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   60 |     for(i=1;i<=n;i++)
      |                ^
      |                yn
cave.cpp:63:15: error: 'l' was not declared in this scope
   63 |         while(l<r)
      |               ^
cave.cpp:63:17: error: 'r' was not declared in this scope
   63 |         while(l<r)
      |                 ^
cave.cpp:68:13: error: 'j' was not declared in this scope
   68 |         for(j=1;j<=n;j++)
      |             ^
cave.cpp:71:17: error: 'l' was not declared in this scope
   71 |                 l--;
      |                 ^
cave.cpp:74:11: error: 'j' was not declared in this scope
   74 |         a[j]=k;
      |           ^
cave.cpp:75:9: error: 'door' was not declared in this scope
   75 |         door[j-1]=i-1;
      |         ^~~~
cave.cpp:77:9: error: 'i' was not declared in this scope; did you mean 'pi'?
   77 |     for(i=0;i<n;i++) b[i]=a[i+1];
      |         ^
      |         pi
cave.cpp:77:15: error: 'n' was not declared in this scope; did you mean 'yn'?
   77 |     for(i=0;i<n;i++) b[i]=a[i+1];
      |               ^
      |               yn
cave.cpp:77:22: error: 'b' was not declared in this scope; did you mean 'db'?
   77 |     for(i=0;i<n;i++) b[i]=a[i+1];
      |                      ^
      |                      db
cave.cpp:78:12: error: 'b' was not declared in this scope; did you mean 'db'?
   78 |     answer(b,door);
      |            ^
      |            db
cave.cpp:78:14: error: 'door' was not declared in this scope
   78 |     answer(b,door);
      |              ^~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:82:5: error: 'n' was not declared in this scope; did you mean '_n'?
   82 |     n=_n;
      |     ^
      |     _n