답안 #1039342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039342 2024-07-30T18:39:12 Z MeGustaElArroz23 popa (BOI18_popa) C++17
0 / 100
28 ms 600 KB
    #include "popa.h"
    #include<bits/stdc++.h>
    using namespace std;
    int tole[1005],tori[1005];
    int calc(int le, int ri)
    {
        if(le>ri)
            return -1;
        if(le==ri)
        {
            tole[le]=tori[le]=-1;
            return le;
        }
        for(int root=le;root<=ri;root++)
        {
            if(query(root,root,le,ri))
            {
                tole[root] = calc(le,root-1);
                tori[root] = calc(root+1,ri);
                return root;
            }
        }
    }

    int solve(int N, int* Left, int* Right)
    {
        for(int i=0;i<N;i++)
            tole[i]=tori[i]=-1;
        int root = calc(0,N-1);
        for(int i=0;i<N;i++)
        {
            Left[i]=-1;
            Right[i]=-1;
        }
        return root;
    }

	void test(int N) {
        int* Left = new int[N];
        int* Right = new int[N];

        int root = solve(N, Left, Right);
        cout << "Root: " << root << endl;

        for (int i = 0; i < N; i++) {
            cout << Left[i] << " " << Right[i] << endl;
        }
    }

Compilation message

popa.cpp: In function 'int calc(int, int)':
popa.cpp:23:5: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     }
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 344 KB too many queries
2 Halted 0 ms 0 KB -