Submission #1072883

# Submission time Handle Problem Language Result Execution time Memory
1072883 2024-08-24T06:26:51 Z Double_Slash Minerals (JOI19_minerals) C++17
6 / 100
8 ms 600 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void dfs(int n, const vector<int> &a, const vector<int> &b) {
    if (n == 1) {
        Answer(a.front(), b.front());
        return;
    }
    int m = (n + 1) >> 1;
    vector<int> al, ar, bl, br;
    for (int i = 0; i < m; ++i) {
        al.emplace_back(a[i]);
        Query(a[i]);
    }
    for (int i = m; i < n; ++i) {
        ar.emplace_back(a[i]);
    }
    for (int i = 0; i < n; ++i) {
        if (Query(b[i]) == m) {
            bl.emplace_back(b[i]);
        } else {
            br.emplace_back(b[i]);
        }
        Query(b[i]);
    }
    for (int i = 0; i < m; ++i) {
        Query(a[i]);
    }
    dfs(m, al, bl);
    dfs(n - m, ar, br);
}

void Solve(int N) {
    mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
    deque<int> arr(N << 1);
    vector<int> a, b;
    iota(arr.begin(), arr.end(), 1);
    shuffle(arr.begin(), arr.end(), gen);
    while (not arr.empty()) {
        int x = arr.back();
        arr.pop_back();
        if (Query(x) == a.size()) {
            b.emplace_back(x);
            Query(x);
            while (b.size() < a.size()) {
                int y = arr.back();
                arr.pop_back();
                if (Query(y) == a.size()) {
                    b.emplace_back(y);
                } else {
                    arr.push_front(y);
                }
                Query(y);
            }
            for (int y: a) Query(y);
            dfs(a.size(), a, b);
            a.clear(), b.clear();
        } else {
            a.emplace_back(x);
        }
    }
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (Query(x) == a.size()) {
      |             ~~~~~~~~~^~~~~~~~~~~
minerals.cpp:51:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 if (Query(y) == a.size()) {
      |                     ~~~~~~~~~^~~~~~~~~~~
# 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 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Incorrect 8 ms 600 KB Wrong Answer [2]
5 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 600 KB Output is correct
8 Incorrect 8 ms 600 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -