답안 #145293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145293 2019-08-19T14:11:11 Z MKopchev popa (BOI18_popa) C++14
0 / 100
1000 ms 376 KB
#include<bits/stdc++.h>
#include<popa.h>
using namespace std;

stack<int> open,idle;
/*
int query(int a,int b,int c,int d)
{
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    int ret;
    cin>>ret;
    return ret;
}
*/
int ask(int a,int b,int c,int d)
{
    while(a>b);
    while(c>d);
    return query(a,b,c,d);
}
int solve(int N, int* Left, int* Right)
{
    Left[0]=-1;
    open.push(0);
    for(int i=1;i<N;i++)
    {
        int prev=-1;
        while(open.size()&&ask(open.top(),i,i,i))
        {
            prev=open.top();
            open.pop();
        }

        Left[i]=prev;
        open.push(i);
    }

    open=idle;
    Right[N-1]=-1;
    open.push(N-1);
    for(int i=N-2;i>=0;i--)
    {
        int prev=-1;
        while(open.size()&&ask(i,open.top(),i,i))
        {
            prev=open.top();
            open.pop();
        }

        Right[i]=prev;
        open.push(i);
    }

    set<int> seen={};
    for(int i=0;i<N;i++)
    {
        seen.insert(Left[i]);
        seen.insert(Right[i]);
    }

    for(int i=0;i<N;i++)
        if(seen.count(i)==0)return i;
    assert(0==1);
}
/*
int n=7,a[10],b[10];
int main()
{
    cout<<solve(n,a,b)<<endl;
    for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
    for(int i=0;i<n;i++)cout<<b[i]<<" ";cout<<endl;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 276 KB not a valid binary tre
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 376 KB too many querie
2 Halted 0 ms 0 KB -