답안 #674004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674004 2022-12-22T14:20:23 Z peijar Super Dango Maker (JOI22_dango3) C++17
22 / 100
768 ms 588 KB
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int randint(int lb, int ub) {
  return uniform_int_distribution<int>(lb, ub)(rng);
}

void Solve(int nbCouleurs, int parCouleur) {
  vector<vector<int>> sol(parCouleur);
  vector<int> bef;
  int tot = nbCouleurs * parCouleur;
  vector<bool> killed(tot);

  for (int iCouleur = 0; iCouleur < nbCouleurs; ++iCouleur) {
    vector<int> indicesRestants;
    for (int i = 0; i < tot; ++i)
      if (!killed[i])
        indicesRestants.push_back(i);
    shuffle(indicesRestants.begin(), indicesRestants.end(), rng);
    int lo = 0, up = indicesRestants.size() - 1;

    while (lo < up) {
      int mid = (lo + up) / 2;
      vector<int> toQuery = bef;
      for (int i = 0; i <= mid; ++i)
        toQuery.push_back(indicesRestants[i] + 1);
      if (Query(toQuery) >= 1)
        up = mid;
      else
        lo = mid + 1;
    }
    vector<int> almostAll = bef;
    for (int i = 0; i < lo; ++i)
      almostAll.push_back(indicesRestants[i] + 1);
    int prv = lo;
    killed[indicesRestants[prv]] = true;
    sol[0].push_back(indicesRestants[prv] + 1);
    for (int iEl = 1; iEl < parCouleur; ++iEl) {
      lo = prv + 1, up = (int)indicesRestants.size() - 1;
      while (lo < up) {
        int mid = (lo + up) / 2;
        vector<int> toQuery = almostAll;
        for (int i = prv + 1; i <= mid; ++i)
          toQuery.push_back(indicesRestants[i] + 1);
        if (Query(toQuery) >= 1)
          up = mid;
        else
          lo = mid + 1;
      }
      killed[indicesRestants[lo]] = true;
      sol[iEl].push_back(indicesRestants[lo] + 1);
      prv = lo;
    }
    bef.push_back(indicesRestants[prv] + 1);
  }
  for (auto &s : sol)
    Answer(s);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 408 KB Output is correct
2 Correct 16 ms 416 KB Output is correct
3 Correct 16 ms 340 KB Output is correct
4 Correct 16 ms 340 KB Output is correct
5 Correct 16 ms 388 KB Output is correct
6 Correct 14 ms 388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 472 KB Output is correct
2 Correct 266 ms 488 KB Output is correct
3 Correct 245 ms 584 KB Output is correct
4 Correct 263 ms 480 KB Output is correct
5 Correct 274 ms 488 KB Output is correct
6 Correct 256 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 768 ms 572 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -