답안 #152094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152094 2019-09-06T11:14:28 Z nicolaalexandra popa (BOI18_popa) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include popa.h
#include <cstring>
#define DIM 1010
using namespace std;
int Left[DIM],Right[DIM],t[DIM];
int T,n,i;
int query(int a, int b, int c, int d){
    int ans;
    cout<<"0 "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    cin>>ans;
    return ans;
}
int solve (int n, int *Left, int *Right){
    cin>>T;
    for (;T--;){
        cin>>n;
        memset (Left,-1,sizeof Left);
        memset (Right,-1,sizeof Right);
        memset (t,-1,sizeof t);
        /// pt ca parcurgerea in inordine e 0..n-1, arborele are structura unui arbore binar de cautare
        /// si tot subarborele lui i contine o subsecv compacta de nr
        /// val[Left[nod]] = val[nod]-1 => pe i incerc sa l pun fix desupra lui i-1
        int rad = 0;
        for (int i=1;i<n;i++){
            int x = i-1;
            while (x >= 0 && !query(x,x,x,i)) /// cat timp x nu e radacina subarborelui
                x = t[x];

            if (x >= 0){
                /// il adaug pe i intre nodurile x si Right[x] (pt ca Left[x] e deja fixat)
                Left[i] = Right[x]; /// subarborele il plasez in stanga pt ca toate nodurile sunt mai mici decat i
                Right[x] = i;
                if (Left[i] >= 0) /// poate sa fie si -1
                    t[Left[i]] = i;
                t[i] = x;

            } else { /// inseamna ca i va fi noua radacina
                Left[i] = rad;
                t[rad] = i;
                rad = i;
            }}
    return rad;
}

Compilation message

popa.cpp:2:10: error: #include expects "FILENAME" or <FILENAME>
 #include popa.h
          ^~~~
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:18:32: 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:19:33: 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:1: error: expected '}' at end of input
 }
 ^
popa.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^