Submission #85122

# Submission time Handle Problem Language Result Execution time Memory
85122 2018-11-18T14:45:17 Z nikolapesic2802 popa (BOI18_popa) C++14
100 / 100
84 ms 720 KB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;

#define ll long long
#define pb push_back
/*bool query(int a,int b,int c,int d)
{
    printf("%i-%i  %i-%i?\n",a,b,c,d);
    int res;
    scanf("%i",&res);
    return res;
}*/
int nxt;
vector<int> parent;
int take(int poz,int n,int* Left,int* Right)
{
    nxt++;
    while(nxt<n&&query(poz,poz,poz,nxt))
    {
        Left[nxt]=Right[poz];
        Right[poz]=nxt;
        parent[nxt]=poz;
        take(nxt,n,Left,Right);
    }
}
int solve(int n,int* Left,int* Right)
{
    for(int i=0;i<n;i++)
    {
        Left[i]=-1;
        Right[i]=-1;
    }
    parent.resize(n);
    fill(parent.begin(),parent.end(),-1);
    int root=-1;
    nxt=0;
    for(int i=0;i<n;i++)
    {
        if(parent[i]==-1){
            if(root!=-1){
                Left[i]=root;
                parent[root]=i;
            }
            root=i;
            assert(nxt==i);
            take(i,n,Left,Right);
        }
    }
    return root;
    int cnt=0,poz;
    for(int i=0;i<n;i++)
    {
        if(parent[i]==-1){
            poz=i;
            cnt++;
        }
    }
    assert(cnt==1);
    return poz;
}

Compilation message

popa.cpp: In function 'int take(int, int, int*, int*)':
popa.cpp:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 14 ms 252 KB Output is correct
2 Correct 9 ms 324 KB Output is correct
3 Correct 8 ms 400 KB Output is correct
4 Correct 9 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 540 KB Output is correct
2 Correct 84 ms 620 KB Output is correct
3 Correct 53 ms 620 KB Output is correct
4 Correct 68 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 720 KB Output is correct
2 Correct 72 ms 720 KB Output is correct
3 Correct 41 ms 720 KB Output is correct
4 Correct 55 ms 720 KB Output is correct