Submission #61936

# Submission time Handle Problem Language Result Execution time Memory
61936 2018-07-27T05:54:25 Z alex(#2140) popa (BOI18_popa) C++11
61 / 100
224 ms 752 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

#include "popa.h"

using namespace std;

int chi[1010][2];

int f(int l, int r)
{
    if(r < l)
        return -1;

    for(int i = 0;; i++)
    {
        if(i % 2 == 0)
        {
            int x = l + i / 2;
            if(x == r - i / 2 || query(l, r, x, x))
            {
                chi[x][0] = f(l, x - 1);
                chi[x][1] = f(x + 1, r);
                return x;
            }
        }
        else
        {
            int x = r - i / 2;
            if(x == l + i / 2 + 1 || query(l, r, x, x))
            {
                chi[x][0] = f(l, x - 1);
                chi[x][1] = f(x + 1, r);
                return x;
            }
        }
    }

    assert(false);
}

int solve(int n, int *l, int *r)
{
    int x = f(0, n - 1);
    for(int i = 0; i < n; i++)
    {
        l[i] = chi[i][0];
        r[i] = chi[i][1];
    }
    return x;
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 300 KB Output is correct
2 Correct 18 ms 436 KB Output is correct
3 Correct 26 ms 436 KB Output is correct
4 Correct 22 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 580 KB Output is correct
2 Correct 78 ms 580 KB Output is correct
3 Correct 126 ms 580 KB Output is correct
4 Correct 224 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 752 KB too many queries
2 Halted 0 ms 0 KB -