Submission #872385

# Submission time Handle Problem Language Result Execution time Memory
872385 2023-11-13T04:10:39 Z browntoad Minerals (JOI19_minerals) C++14
80 / 100
32 ms 2936 KB
#include <bits/stdc++.h>
#include <minerals.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RREP1(i, n) for (int i = (n); i >= 1; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define pb push_back
#define pii pair<int, int>
#define f first
#define s second
 
const ll maxn = 5e5+5;
const ll inf = (1ll<<60);
const ll mod = 1000992299;
 
int ou;
void run(vector<int> &L, vector<int> &R, bool x, bool y){
    if (SZ(L) == 1 && SZ(R) == 1){
        Answer(L[0], R[0]);
        return;
    }
    int mid = SZ(L)/2, b = 0, ret;
    vector<int> lll, lr, rl, rr;
    /*if (SZ(L) == 2 && SZ(R) == 2){
        if (x == 0 && y == 0){
            Query(L[0]);
            ret = Query(R[0]);
            if (ret == ou+2){
                Answer(L[0], R[1]);
                Answer(L[1], R[0]);
            }
            else{
                Answer(L[0], R[0]);
                Answer(L[1], R[1]);
            }
        }
        else if (x == 0 && y == 1){
            Query(R[1]);
            ret = Query(L[0]);
            if (ret == ou){
                Answer(L[0], R[1]);
                Answer(L[1], R[0]);
            }
            else{
                Answer(L[0], R[0]);
                Answer(L[1], R[1]);
            }
        }
        else if (x == 1 && y == 0){
            Query(L[1]);
            ret = Query(R[0]);
            if (ret == ou){
                Answer(L[0], R[1]);
                Answer(L[1], R[0]);
            }
            else{
                Answer(L[0], R[0]);
                Answer(L[1], R[1]);
            }
        }
        else {
            Query(L[0]);
            ret = Query(R[0]);
            if (ret == ou){
                Answer(L[0], R[1]);
                Answer(L[1], R[0]);
            }
            else{
                Answer(L[0], R[0]);
                Answer(L[1], R[1]);
            }
        }
        ou = ret;
        return;
    }
    */
    REP(i, mid){
        ou = Query(L[i]);
        lll.pb(L[i]);
    }
    FOR(i, mid, SZ(L)){
        rl.pb(L[i]);
    }
    if (x == 0 && y == 0){
        REP(i, SZ(R)){
            ret = Query(R[i]);
            if (ret == ou) lr.pb(R[i]);
            else rr.pb(R[i]);
            ou = ret;
        }
        run(lll, lr, 1, 1);
        run(rl, rr, 0, 1);
    }
    else if (x == 0 && y == 1){
        REP(i, SZ(R)){
            ret = Query(R[i]);
            if (ret == ou) lr.pb(R[i]);
            else rr.pb(R[i]);
            ou = ret;
        }
        run(lll, lr, 1, 0);
        run(rl, rr, 0, 0);
    }
    else if (x == 1 && y == 0){
        REP(i, SZ(R)){
            ret = Query(R[i]);
            if (ret != ou) lr.pb(R[i]);
            else rr.pb(R[i]);
            ou = ret;
        }
        run(lll, lr, 0, 1);
        run(rl, rr, 1, 1);
    }
    else {
        REP(i, SZ(R)){
            ret = Query(R[i]);
            if (ret != ou) lr.pb(R[i]);
            else rr.pb(R[i]);
            ou = ret;
        }
        run(lll, lr, 0, 0);
        run(rl, rr, 1, 0);
    }
}
void Solve(int N){
    vector<int> a, b;
    //REP1(i, N) a.pb(i);
    //FOR(i, N+1, 2*N+1) b.pb(i);
    int ret, prev = 0;
    REP1(i, 2*N){
        ret = Query(i);
        if (ret != prev) {
            a.pb(i);
            prev = ret;
        }
        else {
            b.pb(i);
        }
    }
    ou = prev;
    //REP(i, SZ(a)) Query(a[i]);
    run(a, b, 1, 1);
}

Compilation message

minerals.cpp: In function 'void run(std::vector<int>&, std::vector<int>&, bool, bool)':
minerals.cpp:28:24: warning: unused variable 'b' [-Wunused-variable]
   28 |     int mid = SZ(L)/2, b = 0, ret;
      |                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 8 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
19 Correct 25 ms 2792 KB Output is correct
20 Correct 24 ms 2936 KB Output is correct
21 Correct 19 ms 2592 KB Output is correct
22 Correct 19 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
19 Correct 25 ms 2792 KB Output is correct
20 Correct 24 ms 2936 KB Output is correct
21 Correct 19 ms 2592 KB Output is correct
22 Correct 19 ms 2516 KB Output is correct
23 Correct 32 ms 2648 KB Output is correct
24 Correct 28 ms 2804 KB Output is correct
25 Correct 20 ms 2516 KB Output is correct
26 Correct 20 ms 2672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
19 Correct 25 ms 2792 KB Output is correct
20 Correct 24 ms 2936 KB Output is correct
21 Correct 19 ms 2592 KB Output is correct
22 Correct 19 ms 2516 KB Output is correct
23 Correct 32 ms 2648 KB Output is correct
24 Correct 28 ms 2804 KB Output is correct
25 Correct 20 ms 2516 KB Output is correct
26 Correct 20 ms 2672 KB Output is correct
27 Incorrect 25 ms 2896 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
19 Correct 25 ms 2792 KB Output is correct
20 Correct 24 ms 2936 KB Output is correct
21 Correct 19 ms 2592 KB Output is correct
22 Correct 19 ms 2516 KB Output is correct
23 Correct 32 ms 2648 KB Output is correct
24 Correct 28 ms 2804 KB Output is correct
25 Correct 20 ms 2516 KB Output is correct
26 Correct 20 ms 2672 KB Output is correct
27 Incorrect 25 ms 2896 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 596 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 1112 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1016 KB Output is correct
15 Correct 25 ms 2704 KB Output is correct
16 Correct 23 ms 2532 KB Output is correct
17 Correct 19 ms 2664 KB Output is correct
18 Correct 19 ms 2668 KB Output is correct
19 Correct 25 ms 2792 KB Output is correct
20 Correct 24 ms 2936 KB Output is correct
21 Correct 19 ms 2592 KB Output is correct
22 Correct 19 ms 2516 KB Output is correct
23 Correct 32 ms 2648 KB Output is correct
24 Correct 28 ms 2804 KB Output is correct
25 Correct 20 ms 2516 KB Output is correct
26 Correct 20 ms 2672 KB Output is correct
27 Incorrect 25 ms 2896 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -