Submission #904926

# Submission time Handle Problem Language Result Execution time Memory
904926 2024-01-12T11:27:13 Z nguyentunglam Super Dango Maker (JOI22_dango3) C++17
100 / 100
177 ms 708 KB
#include "dango3.h"
#include<bits/stdc++.h>

#include <vector>

using namespace std;

mt19937 rng(1);


void Solve(int n, int m) {
  vector<int> p;
  for(int i = 1; i <= n * m; i++) p.push_back(i);
  for(int group = 1; group <= m; group++) {
    shuffle(p.begin(), p.end(), rng);
    int l = n, r = p.size(), last = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      vector<int> tmp;
      for(int i = 0; i < mid; i++) tmp.push_back(p[i]);
      if (Query(tmp)) {
        r = mid - 1;
        last = mid;
      } else l = mid + 1;
    }
    assert(last);
    vector<int> _p, ans;
    for(int i = last; i < p.size(); i++) _p.push_back(p[i]);
    for(int i = 0; i < last; i++) ans.push_back(p[i]);
    for(int i = 0; i < last; i++) {
      vector<int> _ans;
      for(int &j : ans) if (j != p[i]) _ans.push_back(j);
      if (Query(_ans)) {
        ans = _ans;
        _p.push_back(p[i]);
      }
    }
    p = _p;
    Answer(ans);
  }
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:18:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |       int mid = l + r >> 1;
      |                 ~~^~~
dango3.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = last; i < p.size(); i++) _p.push_back(p[i]);
      |                       ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 448 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 604 KB Output is correct
2 Correct 43 ms 604 KB Output is correct
3 Correct 42 ms 604 KB Output is correct
4 Correct 50 ms 604 KB Output is correct
5 Correct 37 ms 604 KB Output is correct
6 Correct 35 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 158 ms 704 KB Output is correct
2 Correct 157 ms 604 KB Output is correct
3 Correct 172 ms 604 KB Output is correct
4 Correct 177 ms 708 KB Output is correct
5 Correct 172 ms 704 KB Output is correct
6 Correct 149 ms 604 KB Output is correct