Submission #937331

# Submission time Handle Problem Language Result Execution time Memory
937331 2024-03-03T21:46:37 Z freedommo33 Chameleon's Love (JOI20_chameleon) C++17
0 / 100
1 ms 344 KB
#include "chameleon.h"
#include <vector>
#include <iostream>

using namespace std;

// Function to find a pair given one of the chameleons
void findPair(int n, int x, vector<bool>& found) {
    int low = 1, high = 2 * n, mid;
    while (low < high) {
        mid = (low + high) / 2;
        vector<int> query = {x};
        for (int i = 1; i <= mid; ++i) {
            if (!found[i]) query.push_back(i);
        }
        int result = Query(query);
        if (result < query.size()) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    Answer(x, low);
    found[x] = found[low] = true;
}

void Solve(int N) {
    vector<bool> found(2 * N + 1, false);
    for (int i = 1; i <= 2 * N; ++i) {
        if (!found[i]) {
            findPair(N, i, found);
        }
    }
}

Compilation message

chameleon.cpp: In function 'void findPair(int, int, std::vector<bool>&)':
chameleon.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if (result < query.size()) {
      |             ~~~~~~~^~~~~~~~~~~~~~
# 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 0 ms 344 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -