Submission #874242

# Submission time Handle Problem Language Result Execution time Memory
874242 2023-11-16T14:17:37 Z LucaLucaM Super Dango Maker (JOI22_dango3) C++17
7 / 100
2360 ms 872 KB
#include "dango3.h"
#ifdef LOCAL
#include "grader.cpp"
#endif // LOCAL

#include <vector>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iostream>

std::mt19937 rng(123);

void Solve(int n, int m) {
  /**

  sol in O(n * m^2) query uri:

  pornesc cu toate valorile ramase si de fiecare data incerc sa scot cate 1

  **/

  auto query = [&] (std::vector<int> v) {
    return Query(v);
  };

  std::function<std::vector<int>(std::vector<int>)> exclude = [&] (std::vector<int> v) {
    bool dont[n * m + 1] = {};
    for (const auto &x : v) {
      dont[x] = true;
    }
    std::vector<int> w;
    for (int i = 1; i <= n * m; i++) {
      if (!dont[i]) {
        w.push_back(i);
      }
    }
    return w;
  };

  bool taken[n * m + 1] = {};

  for (int rep = 0; rep < m; rep++) {
    std::vector<int> cand;
    for (int i = 1; i <= n * m; i++) {
      if (!taken[i]) {
        cand.push_back(i);
      }
    }
    assert((int) cand.size() == n * m - rep * n);
    std::vector<int> ret;
    ret.push_back(cand[0]);
    for (int i = 1; i < (int) cand.size() && (int) ret.size() < n; i++) {
      std::vector<int> nw = ret;
      nw.push_back(cand[i]);
      if (query(exclude(ret)) == query(exclude(nw))) {
        ret.push_back(cand[i]);
      }
    }
//    std::cout << "! " << (int) ret.size() << '\n';
    Answer(ret);
    for (const auto &x : ret) {
      taken[x] = true;
    }
  }

}
/**


3 2
3 3 1 2 1 2

4 4
2 2 3 2 4 4 3 2 3 1 1 3 4 1 4 1


**/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 348 KB Output is correct
2 Correct 28 ms 348 KB Output is correct
3 Correct 48 ms 536 KB Output is correct
4 Correct 49 ms 348 KB Output is correct
5 Correct 11 ms 348 KB Output is correct
6 Correct 13 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1035 ms 660 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2360 ms 872 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -