Submission #997324

# Submission time Handle Problem Language Result Execution time Memory
997324 2024-06-12T05:51:54 Z 12345678 Minerals (JOI19_minerals) C++17
40 / 100
23 ms 6656 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=5e4+5;

int n, p, c, l[nx], r[nx], t;
vector<int> used, v, qrs[nx];

void Solve(int N) {
    v.push_back(0);
    used.push_back(0);
    for (int i=1; i<=2*N; i++)
    {
        c=Query(i);
        if (c==p) v.push_back(i);
        else used.push_back(i), p=c;
    }
    for (int i=1; i<=N; i++) l[i]=1, r[i]=N;
    while (++t)
    {
        bool f=1;
        for (int i=1; i<=N; i++) qrs[i].clear();
        for (int i=1; i<=N; i++) if (l[i]!=r[i]) f=0, qrs[(l[i]+r[i])/2].push_back(i);
        if (f) break;
        //cout<<"bsearch\n";
        //for (int i=1; i<=N; i++) cout<<i<<' '<<v[i]<<' '<<l[i]<<' '<<r[i]<<'\n';
        if (t%2)
        {
            p=N;
            for (int i=N; i>=1; i--)
            {
                for (auto x:qrs[i])
                {
                    //cout<<"here "<<x<<' '<<p<<'\n';
                    if (Query(v[x])==p) r[x]=i;
                    else l[x]=i+1, p--;
                }
                p=Query(used[i]);
            }
        }
        else
        {
            p=0;
            for (int i=1; i<=N; i++)
            {
                p=Query(used[i]);
                for (auto x:qrs[i])
                {
                    if (Query(v[x])==p) r[x]=i;
                    else l[x]=i+1, p++;
                }
            }
        }
    }
    for (int i=1; i<=N; i++) Answer(v[i], used[l[i]]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 2 ms 2904 KB Output is correct
4 Correct 5 ms 3432 KB Output is correct
5 Correct 9 ms 4184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2904 KB Output is correct
8 Correct 5 ms 3432 KB Output is correct
9 Correct 9 ms 4184 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 7 ms 3672 KB Output is correct
12 Correct 10 ms 4060 KB Output is correct
13 Correct 6 ms 4184 KB Output is correct
14 Correct 6 ms 4184 KB Output is correct
15 Incorrect 23 ms 6656 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -