Submission #661270

# Submission time Handle Problem Language Result Execution time Memory
661270 2022-11-25T06:29:21 Z Alex_tz307 Super Dango Maker (JOI22_dango3) C++17
100 / 100
3930 ms 884 KB
#include <bits/stdc++.h>
#include "dango3.h"
 
using namespace std;
 
const int kLog = 4;
 
void Solve(int N, int M) {
  vector<vector<int>> groups(M);
  auto check = [&](const vector<int> &a) -> bool {
    vector<bool> mark(1 + N * M);
    for (const int &x : a) {
      mark[x] = true;
    }
    vector<int> q;
    for (int i = 1; i <= N * M; ++i) {
      if (!mark[i]) {
        q.emplace_back(i);
      }
    }
    int res = M - Query(q);
    return (res == 2);
  };
  for (int i = 1; i <= N * M; ++i) {
    int colour = 0;
    if (i != 1) {
      for (int k = kLog; k >= 0; --k) {
        int newColour = (colour | (1 << k));
        if (newColour < M) {
          groups[newColour - 1].emplace_back(i);
          if (check(groups[newColour - 1])) {
            colour = newColour;
          }
          groups[newColour - 1].pop_back();
        }
      }
    }
    groups[colour].emplace_back(i);
  }
  for (int i = 0; i < M; ++i) {
    Answer(groups[i]);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 340 KB Output is correct
2 Correct 33 ms 352 KB Output is correct
3 Correct 32 ms 372 KB Output is correct
4 Correct 24 ms 364 KB Output is correct
5 Correct 32 ms 340 KB Output is correct
6 Correct 27 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 998 ms 472 KB Output is correct
2 Correct 941 ms 448 KB Output is correct
3 Correct 983 ms 824 KB Output is correct
4 Correct 1002 ms 488 KB Output is correct
5 Correct 927 ms 568 KB Output is correct
6 Correct 924 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3930 ms 884 KB Output is correct
2 Correct 3877 ms 584 KB Output is correct
3 Correct 3801 ms 672 KB Output is correct
4 Correct 3800 ms 628 KB Output is correct
5 Correct 3833 ms 588 KB Output is correct
6 Correct 3733 ms 580 KB Output is correct