Submission #993547

# Submission time Handle Problem Language Result Execution time Memory
993547 2024-06-06T03:52:21 Z yellowtoad Super Dango Maker (JOI22_dango3) C++17
100 / 100
97 ms 760 KB
#include "dango3.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
namespace {
 
vector<int> cur, tmp, ans, v, q;
bool b[10010];
 
}  // namespace
 
void Solve(int n, int m) {
  for (int i = 1; i <= n*m; i++) cur.push_back(i);
  random_shuffle(cur.begin(),cur.end());
  for (int _ = 1; _ < m; _++) {
    int l = 0, r = cur.size()-1;
    while (l <= r) {
      int mid = (l+r)/2;
      q.clear();
      for (int i = 0; i <= mid; i++) q.push_back(cur[i]);
      if (Query(q)) r = mid-1;
      else l = mid+1;
    }
    int ll = l, rr = r;
    b[cur[ll]] = 1;
    v = {cur[ll]};
    for (int i = 0; i <= rr; i += 8) {
      while (1) {
        q = v;
        for (int j = i+8; j <= rr; j++) if (!b[cur[j]]) q.push_back(cur[j]);
        if (Query(q)) break;
        tmp.clear();
        for (int j = i; j < min(i+8,(int)rr+1); j++) if (!b[cur[j]]) tmp.push_back(cur[j]);
        l = 0; r = (int)tmp.size()-1;
        while (l < r) {
          int mid = (l+r)/2;
          q = v;
          for (int j = mid+1; j < tmp.size(); j++) q.push_back(tmp[j]);
          for (int j = i+8; j <= rr; j++) if (!b[cur[j]]) q.push_back(cur[j]);
          if (Query(q)) l = mid+1;
          else r = mid;
        }
        b[tmp[l]] = 1;
        v.push_back(tmp[l]);
        if (v.size() == n) goto skip;
      }
    }
    skip:;
    tmp.clear();
    for (int i = 0; i < cur.size(); i++) if (!b[cur[i]]) tmp.push_back(cur[i]);
    Answer(v);
    cur = tmp;
  }
  Answer(cur);
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:40:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |           for (int j = mid+1; j < tmp.size(); j++) q.push_back(tmp[j]);
      |                               ~~^~~~~~~~~~~~
dango3.cpp:47:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if (v.size() == n) goto skip;
      |             ~~~~~~~~~^~~~
dango3.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (int i = 0; i < cur.size(); i++) if (!b[cur[i]]) tmp.push_back(cur[i]);
      |                     ~~^~~~~~~~~~~~
# 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 448 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 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 604 KB Output is correct
2 Correct 24 ms 604 KB Output is correct
3 Correct 23 ms 604 KB Output is correct
4 Correct 24 ms 604 KB Output is correct
5 Correct 33 ms 600 KB Output is correct
6 Correct 23 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 756 KB Output is correct
2 Correct 96 ms 748 KB Output is correct
3 Correct 96 ms 600 KB Output is correct
4 Correct 89 ms 600 KB Output is correct
5 Correct 97 ms 600 KB Output is correct
6 Correct 86 ms 760 KB Output is correct