Submission #417415

# Submission time Handle Problem Language Result Execution time Memory
417415 2021-06-03T17:04:51 Z iulia2100 Minerals (JOI19_minerals) C++14
25 / 100
867 ms 940 KB
#include <iostream>
#include "minerals.h"

using namespace std;

//ifstream cin ("idk.in");
//ofstream cout ("idk.out");

const int N = 43005;

struct idk {
    int st, dr;
} interval[N + N];

int n, last_ans;
bool in_set[N + N];

void bs(int st, int dr, int other_half_st, int other_half_dr) {
    int x = last_ans;
    if (other_half_st > dr) { //sunt in partea stanga. Daca sunt in dreapta cunosc deja intervalele
        for (int i = 1; i < st; ++i)    {
            if (in_set[i])  {
                x = Query(i);
                in_set[i] = false;
                last_ans = x;
            }
        }
        for (int i = st; i <= dr; ++i)  {
            if (!in_set[i]) {
                x = Query(i);
                in_set[i] = true;
                last_ans = x;
            }
        }
        for (int i = dr + 1; i <= n + n; ++i)   {
            if (in_set[i])  {
                x = Query(i);
                in_set[i] = false;
                last_ans = x;
            }
        }
        for (int i = n + 1; i <= n + n; ++i)    {
            if (interval[i].dr < st || interval[i].st > dr)
                continue;
            int aux = Query(i);
            last_ans = aux;
            if (aux == x)   {
                interval[i].st = st, interval[i].dr = dr;
                last_ans = Query(i);
            } else  {
                last_ans = Query(i);
                interval[i].st = other_half_st;
                interval[i].dr = other_half_dr;
            }
        }
    }
    if (st == dr)   {
        return;
    }
    bs(st, (st + dr) / 2, (st + dr) / 2 + 1, dr);
    bs((st + dr) / 2 + 1, dr, st, (st + dr) / 2);
}

void Solve(int aux_n)   {
    n = aux_n;
    for (int i = 1; i <= n; ++i)
        interval[i + n] = {1, n};
    bs(1, n / 2, n / 2 + 1, n);
    bs(n / 2 + 1, n, 1, n / 2);
    for (int i = 1; i <= n; ++i)    {
        Answer(interval[i + n].st, i + n);
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 328 KB Output is correct
2 Correct 14 ms 328 KB Output is correct
3 Correct 57 ms 404 KB Output is correct
4 Correct 230 ms 512 KB Output is correct
5 Correct 867 ms 940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -