Submission #997388

# Submission time Handle Problem Language Result Execution time Memory
997388 2024-06-12T08:30:38 Z 12345678 Minerals (JOI19_minerals) C++17
75 / 100
26 ms 2900 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=5e4+5;

int p, c;
vector<int> l, r;

int update(int x)
{
    p=Query(x);
    swap(c, p);
    return c!=p;
}

void solve(vector<int> &l, vector<int> &r, int t)
{
    int sz=l.size();
    //cout<<"solve "<<sz<<'\n';
    //for (int i=0; i<sz; i++) cout<<i<<' '<<l[i]<<' '<<r[i]<<'\n';
    if (sz==1) return Answer(l[0], r[0]), void();
    int md=(sz-1)/2;
    vector<int> l1, l2, r1, r2;
    for (int i=0; i<=md; i++) l1.push_back(l[i]), update(l[i]);
    for (int i=md+1; i<sz; i++) r1.push_back(l[i]);
    for (int i=0; i<sz; i++)
    {
        if (update(r[i])==t) l2.push_back(r[i]);
        else r2.push_back(r[i]); 
    }
    //cout<<"debug "<<l1.size()<<' '<<l2.size()<<' '<<r1.size()<<' '<<r2.size()<<'\n';
    solve(l1, l2, !t); solve(r1, r2, t);
}

void Solve(int N) {
    for (int i=1; i<=2*N; i++) 
    {
        if (update(i)) l.push_back(i);
        else r.push_back(i);
    }
    solve(l, r, 1);
}

/*
5
4 7
1 2
8 3
6 10
9 5
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 7 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 26 ms 2900 KB Output is correct
20 Correct 22 ms 2648 KB Output is correct
21 Correct 17 ms 2516 KB Output is correct
22 Correct 21 ms 2608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 26 ms 2900 KB Output is correct
20 Correct 22 ms 2648 KB Output is correct
21 Correct 17 ms 2516 KB Output is correct
22 Correct 21 ms 2608 KB Output is correct
23 Incorrect 23 ms 2648 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 26 ms 2900 KB Output is correct
20 Correct 22 ms 2648 KB Output is correct
21 Correct 17 ms 2516 KB Output is correct
22 Correct 21 ms 2608 KB Output is correct
23 Incorrect 23 ms 2648 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 26 ms 2900 KB Output is correct
20 Correct 22 ms 2648 KB Output is correct
21 Correct 17 ms 2516 KB Output is correct
22 Correct 21 ms 2608 KB Output is correct
23 Incorrect 23 ms 2648 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 7 ms 856 KB Output is correct
12 Correct 8 ms 1296 KB Output is correct
13 Correct 8 ms 1112 KB Output is correct
14 Correct 8 ms 1224 KB Output is correct
15 Correct 21 ms 2648 KB Output is correct
16 Correct 25 ms 2648 KB Output is correct
17 Correct 17 ms 2516 KB Output is correct
18 Correct 17 ms 2392 KB Output is correct
19 Correct 26 ms 2900 KB Output is correct
20 Correct 22 ms 2648 KB Output is correct
21 Correct 17 ms 2516 KB Output is correct
22 Correct 21 ms 2608 KB Output is correct
23 Incorrect 23 ms 2648 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -