이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
_ _ __ _ _ _ _ _ _
|a ||t ||o d | |o |
| __ _| | _ | __| _ |
| __ |/_ | __ /__\ / _\|
**/
#include <bits/stdc++.h>
#include "dango3.h"
using namespace std;
typedef long long ll;
int Query (const vector <int> &x);
void Answer (const vector <int> &a);
void Solve (int N, int M) {
int A[N * M + 2];
fill(A, A + N * M + 2, 0);
int l, r;
l = 1; r = N * M;
while (l < r) {
int mid = (l + r) / 2;
vector <int> x;
for (int i = 1; i <= mid; i++) {
x.push_back(i);
}
if (Query(x) > 0) {
r = mid;
} else {
l = mid + 1;
}
}
vector <int> with_color[N + 2];
int curr = 0;
int k = l;
while (k > 0) {
curr++;
int p = k;
while (p <= N * M) {
A[p] = curr;
with_color[curr].push_back(p);
l = p + 1; r = N * M + 1;
while (l < r) {
int mid = (l + r) / 2;
vector <int> x;
for (int i = 1; i <= mid; i++) {
if (A[i] == 0) {
x.push_back(i);
}
}
for (int c = 1; c < curr; c++) {
x.push_back(with_color[c].back());
}
if (Query(x) > 0) {
r = mid;
} else {
l = mid + 1;
}
}
p = l;
}
k--;
while (k > 0) {
vector <int> x;
for (int i = 1; i < k; i++) {
x.push_back(i);
}
for (int c = 1; c <= curr; c++) {
x.push_back(with_color[c].back());
}
if (Query(x) == 0) {
break;
}
k--;
}
}
for (int t = 1; t <= M; t++) {
vector <int> a;
for (int c = 1; c <= N; c++) {
a.push_back(with_color[c].back());
with_color[c].pop_back();
}
Answer(a);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |