답안 #101432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101432 2019-03-19T01:59:14 Z dantoh000 popa (BOI18_popa) C++14
컴파일 오류
0 ms 0 KB
#include "popa.h"
#include <bits/stdc++.h>
using namespace std;
void guess(int s, int e, int p, int* left, int* right){
    //printf("at %d %d from %d\n",s,e,p);
    if (s > e){
        left[s] = -1;
        right[s] = -1;
        return;
    }
    if (s == e){
        if (e == p-1){
            left[p] = e;
        }
        else if (s == p+1){
            right[p] = s;
        }
        left[s] = right[s] = -1;
        return;
    }
    int ans = 0;
    for (int i = s; i <= e; i++){
        if (query(s,i,i,e)){
            ans = i;
            break;
        }
    }
    if (e == p-1){
        left[p] = ans;
    }
    else if (s == p+1){
        right[p] = ans;
    }
    if (s <= ans-1) guess(s,ans-1,ans,left,right);
    else left[ans] = -1;
    if (ans+1 <= e) guess(ans+1,e,ans,left,right);
    else right[ans] = -1;
    return;
}
int solve(int N, int* left, int* right){
    memset(left,-1,sizeof(left));
    memset(right,-1,sizeof(right));
    int s;
    for (int i = 0; i < n; i++){
        if (query(0,i,i,n-1)){
            s = i;
            break;
        }
    }
    guess(0,s-1,s,left,right);
    guess(s+1,n-1,s,left,right);
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:41:26: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(left,-1,sizeof(left));
                          ^
popa.cpp:42:27: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(right,-1,sizeof(right));
                           ^
popa.cpp:44:25: error: 'n' was not declared in this scope
     for (int i = 0; i < n; i++){
                         ^
popa.cpp:51:15: error: 'n' was not declared in this scope
     guess(s+1,n-1,s,left,right);
               ^
popa.cpp:52:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^