Submission #996128

# Submission time Handle Problem Language Result Execution time Memory
996128 2024-06-10T08:11:54 Z 12345678 Park (JOI17_park) C++17
0 / 100
1 ms 604 KB
#include "park.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1500;

static int Place[1400];

int n, pa[nx], used[nx], l, r;
vector<int> d[nx], x, edg[nx];

int findnode(int u)
{
    int l=0, r=n-1;
    while (l<r)
    {
        int md=(l+r)/2;
        for (int i=0; i<n; i++) Place[i]=used[i];
        for (int i=0; i<=md; i++) Place[i]=1;
        if (Ask(0, u, Place)) r=md;
        else l=md+1;
    }
    return l;
}

void solve(int u)
{
	used[u]=1;
    for (int i=0; i<n; i++) Place[i]=used[i];
    if (!Ask(0, u, Place))
    {
        int v=findnode(u);
        solve(v);
        solve(u);
    }
    else
    {
        while (1)
        {
            vector<int> x;
            for (int i=0; i<n; i++) if (used[i]&&i!=u) x.push_back(i);
            for (int i=0; i<n; i++) Place[i]=used[i];
            for (auto tmp:edg[u]) Place[tmp]=0;
            Place[u]=1;
            if (!Place[0]||!Ask(0, u, Place)) break;
            int l=0, r=x.size()-1;
            while (l<r)
            {
                int md=(l+r)/2;
                for (int i=0; i<n; i++) Place[i]=0;
                for (int i=0; i<=md; i++) Place[x[i]]=1;
                for (auto tmp:edg[u]) Place[tmp]=0;
                Place[u]=1;
                if (!Place[0]||Ask(0, u, Place)) r=md;
                else l=md+1;
            }
            Answer(min(x[l], u), max(x[l], u));
            edg[u].push_back(x[l]);
        }
    }
}

void Detect(int T, int N) {
	n=N;
	used[0]=1;
	for (int i=1; i<N; i++) if (!used[i]) solve(i);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -