QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#844723 | #8818. Colorful Graph 3 | hos_lyric# | AC ✓ | 24ms | 9704kb | C++14 | 9.5kb | 2025-01-06 10:33:32 | 2025-01-06 10:33:33 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
// upper bound: 2(N-1) (by 2 stars)
constexpr int LIM = 300'010;
int minF[LIM], maxF[LIM];
void init() {
fill(minF, minF + LIM, 1001001001);
fill(maxF, maxF + LIM, -1);
for (int r = 1; ; ++r) {
for (int f = r*(r-1)/2; f < (r+1)*r/2; ++f) {
const int d = f - (r-1);
if (d >= LIM) {
cerr<<"minF = ";pv(minF,minF+20);
cerr<<"maxF = ";pv(maxF,maxF+20);
return;
}
chmin(minF[d], f);
chmax(maxF[d], f);
}
}
}
namespace exper {
// [l, r)^n, increasing
template <class F> void doArraysIncrRec(int n, int l, int r, F f, int i, vector<int> &as) {
if (i == n) {
f(as);
} else {
for (as[i] = i ? as[i - 1] : l; as[i] < r; ++as[i]) doArraysIncrRec(n, l, r, f, i + 1, as);
}
}
template <class F> void doArraysIncr(int n, int l, int r, F f) {
vector<int> as(n);
doArraysIncrRec(n, l, r, f, 0, as);
}
void run() {
constexpr int LIM_K = 5;
constexpr int LIM_N = 10;
for (int K0 = 0; K0 <= LIM_K; ++K0) for (int K1 = 0; K1 <= LIM_K; ++K1) if (K0 + K1 >= 2) {
vector<int> Ms;
for (int N = 2; N <= LIM_N; ++N) {
int minM = 1001001001;
vector<pair<vector<int>, vector<int>>> bests;
doArraysIncr(K0, 0, (N-1) + 1, [&](const vector<int> &E) -> void {
doArraysIncr(K1, 0, N*(N-1)/2 + 1, [&](const vector<int> &F) -> void {
int m = 0;
for (int k = 0; k < K0; ++k) m += E[k];
for (int l = 0; l < K1; ++l) m += F[l];
for (int k = 0; k < K0; ++k) if (m - E[k] < N - 1) return;
for (int l = 0; l < K1; ++l) {
// contract other colors
const int n = max(N - (m - F[l]), 1);
if (F[l] < n*(n-1)/2) return;
}
if (chmin(minM, m)) bests.clear();
if (minM == m) bests.emplace_back(E, F);
});
});
Ms.push_back(minM);
cout << K0 << " " << K1 << " " << N << ": " << minM << endl;
// for (const auto &best : bests) cout << " " << best << endl;
}
cerr << K0 << " " << K1 << " " << Ms << endl;
}
/*
0 2 [1, 2, 4, 5, 6, 8, 10, 11, 12]
0 3 [1, 2, 3, 5, 6, 7, 8, 9, 11]
0 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
0 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
1 1 [1, 3, 4, 6, 8, 9, 11, 13, 15]
1 2 [1, 2, 4, 5, 6, 7, 9, 10, 12]
1 3 [1, 2, 3, 5, 6, 7, 8, 9, 10]
1 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
1 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
2 0 [2, 4, 6, 8, 10, 12, 14, 16, 18]
2 1 [1, 3, 4, 5, 7, 8, 10, 11, 12]
2 2 [1, 2, 4, 5, 6, 7, 8, 10, 11]
2 3 [1, 2, 3, 5, 6, 7, 8, 9, 10]
2 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
2 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
3 0 [2, 3, 5, 6, 8, 9, 11, 12, 14]
3 1 [1, 3, 4, 5, 6, 8, 9, 10, 12]
3 2 [1, 2, 4, 5, 6, 7, 8, 9, 11]
3 3 [1, 2, 3, 5, 6, 7, 8, 9, 10]
3 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
3 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
4 0 [2, 3, 4, 6, 7, 8, 10, 11, 12]
4 1 [1, 3, 4, 5, 6, 7, 9, 10, 11]
4 2 [1, 2, 4, 5, 6, 7, 8, 9, 10]
4 3 [1, 2, 3, 5, 6, 7, 8, 9, 10]
4 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
4 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
5 0 [2, 3, 4, 5, 7, 8, 9, 10, 12]
5 1 [1, 3, 4, 5, 6, 7, 8, 10, 11]
5 2 [1, 2, 4, 5, 6, 7, 8, 9, 10]
5 3 [1, 2, 3, 5, 6, 7, 8, 9, 10]
5 4 [1, 2, 3, 4, 6, 7, 8, 9, 10]
5 5 [1, 2, 3, 4, 5, 7, 8, 9, 10]
*/
}
} // exper
/*
c >= 2 ==> star OK
K0 colors with c = 0: E[k] edges
K1 colors with c = 1: F[l] edges
necessary condition to be connected?
contract other colors:
c = 0: 1 point
c = 1: complete
M = \sum[k] E[k] + \sum[l] E[l]
M - E[k] >= N - 1
M - F[l] >= N - R[l], where binom(R[l],2) <= F[l]
M - (N-1) >= E[k]
M - (N-1) >= F[l] - (R[l]-1)
RHS: almost same
colorful paths (only c = 1) from vertex 0,
then create cycles: connect endpoints by colorful paths
*/
struct Solver {
int N, K;
vector<int> C;
int M;
vector<pair<pair<int, int>, int>> edges;
void ae(int u, int v, int k) {
edges.emplace_back(make_pair(u, v), k);
}
void run() {
for (int k = 0; k < K; ++k) if (C[k] >= 2) {
M = N-1;
for (int u = 1; u < N; ++u) ae(0, u, k);
return;
}
vector<int> colorss[2];
for (int k = 0; k < K; ++k) colorss[C[k]].push_back(k);
const int K0 = colorss[0].size();
const int K1 = colorss[1].size();
int minM = 0, maxM = K1;
int maxD = 0;
vector<int> ds(K, 0);
for (; ; ) {
for (int k = 0; k < K; ++k) {
M = max((N-1) + maxD, minM);
if (M <= maxM) goto found;
if (k < K0) {
minM += 1;
maxM += 1;
} else {
minM += (minF[ds[k] + 1] - minF[ds[k]]);
maxM += (maxF[ds[k] + 1] - maxF[ds[k]]);
}
chmax(maxD, ++ds[k]);
}
}
found:{}
vector<int> es(K0), fs(K1), rs(K1);
{
int m = M;
for (int k = 0; k < K0; ++k) m -= es[k] = ds[k];
for (int k = 0; k < K1; ++k) m -= fs[k] = minF[ds[K0 + k]];
for (int k = 0; k < K1; ++k) {
const int d = ds[K0 + k];
const int t = min(m, maxF[d] - minF[d]);
m -= t;
fs[k] += t;
}
assert(m == 0);
}
for (int k = 0; k < K1; ++k) rs[k] = (fs[k] - ds[K0 + k]) + 1;
// cerr<<K0<<" "<<K1<<" "<<N<<": M = "<<1<<", ds = "<<ds<<", es = "<<es<<", fs = "<<fs<<", rs = "<<rs<<endl;
const int maxR = K1 ? *max_element(rs.begin(), rs.end()) : 1;
int n = 1;
vector<int> us(maxR-1, 0);
for (int k = 0; k < K1; ++k) {
for (int i = 0; i < rs[k]-1; ++i) {
const int v = n++;
ae(us[i], v, colorss[1][k]);
us[i] = v;
}
}
auto go = [&](int u, int v) -> void {
int len = 0;
for (int k = 0; k < K; ++k) if (ds[k]) {
--ds[k];
++len;
}
vector<int> path(len + 1);
path[0] = u;
path[len] = v;
for (int k = 1; k < len; ++k) path[k] = n++;
for (int k = 0; k < len; ++k) ae(path[k], path[k + 1], (k < K0) ? colorss[0][k] : colorss[1][k - K0]);
};
for (int i = 0; i < maxR-1; ++i) for (int j = 0; j < i; ++j) {
if (ds[0]) go(us[i], us[j]);
}
for (; ds[0]; ) go(0, 0);
assert(n == N);
}
void judge() {
assert((int)edges.size() == M);
for (const auto &edge : edges) {
const int u = edge.first.first;
const int v = edge.first.second;
const int k = edge.second;
assert(0 <= u); assert(u < N);
assert(0 <= v); assert(v < N);
assert(0 <= k); assert(k < K);
}
for (int kk = 0; kk < K; ++kk) {
vector<vector<int>> d(N, vector<int>(N, N));
for (int u = 0; u < N; ++u) d[u][u] = 0;
for (const auto &edge : edges) {
const int u = edge.first.first;
const int v = edge.first.second;
const int k = edge.second;
chmin(d[u][v], (kk == k) ? 1 : 0);
chmin(d[v][u], (kk == k) ? 1 : 0);
}
for (int w = 0; w < N; ++w) for (int u = 0; u < N; ++u) for (int v = 0; v < N; ++v) chmin(d[u][v], d[u][w] + d[w][v]);
for (int u = 0; u < N; ++u) for (int v = 0; v < N; ++v) assert(d[u][v] <= C[kk]);
}
}
void input() {
scanf("%d%d", &N, &K);
C.resize(K);
for (int k = 0; k < K; ++k) {
scanf("%d", &C[k]);
}
}
void output() {
printf("%d\n", M);
for (const auto &edge : edges) {
const int u = edge.first.first;
const int v = edge.first.second;
const int k = edge.second;
printf("%d %d %d\n", u + 1, v + 1, k + 1);
}
}
};
void stress() {
constexpr int LIM_K = 10;
constexpr int LIM_N = 20;
for (int K0 = 0; K0 <= LIM_K; ++K0) for (int K1 = 0; K1 <= LIM_K; ++K1) if (K0 + K1 >= 2) {
vector<int> Ms;
for (int N = 2; N <= LIM_N; ++N) {
Solver solver;
solver.N = N;
solver.K = K0 + K1;
for (int k = 0; k < K0; ++k) solver.C.push_back(0);
for (int k = 0; k < K1; ++k) solver.C.push_back(1);
solver.run();
solver.judge();
Ms.push_back(solver.M);
}
cerr << K0 << " " << K1 << " " << Ms << endl;
}
}
int main() {
init();
// exper::run();
// stress();
for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
Solver solver;
solver.input();
solver.run();
solver.output();
#ifdef LOCAL
solver.judge();
#endif
}
#ifndef LOCAL
break;
#endif
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 6108kb
input:
3 4 2 1 1 2 2 0 0 5 2 3 1
output:
4 1 2 1 1 3 1 2 4 2 3 4 1 2 1 2 1 2 1 2 4 1 2 1 1 3 1 1 4 1 1 5 1
result:
ok orz (3 test cases)
Test #2:
score: 0
Accepted
time: 15ms
memory: 6432kb
input:
4645 2 2 0 0 2 2 0 1 2 2 1 1 3 2 0 0 3 2 0 1 3 2 1 1 3 3 0 0 0 3 3 1 0 0 3 3 1 0 1 3 3 1 1 1 4 2 0 0 4 2 1 0 4 2 1 1 4 3 0 0 0 4 3 0 0 1 4 3 0 1 1 4 3 1 1 1 4 4 0 0 0 0 4 4 0 1 0 0 4 4 1 1 0 0 4 4 1 1 1 0 4 4 1 1 1 1 5 2 0 0 5 2 1 0 5 2 1 1 5 3 0 0 0 5 3 0 1 0 5 3 1 1 0 5 3 1 1 1 5 4 0 0 0 0 5 4 0 1...
output:
2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 4 1 2 1 2 1 2 1 3 1 3 1 2 3 1 2 2 1 3 1 3 1 2 2 1 2 1 2 3 2 3 1 2 1 2 3 2 3 1 3 3 1 2 1 1 3 2 3 1 3 2 1 2 1 2 3 3 2 1 2 1 2 3 2 6 1 2 1 2 1 2 1 3 1 3 1 2 1 4 1 4 1 2 4 1 2 1 1 3 1 3 4 2 4 2 1 4 1 2 1 1 3 1 2 4 2 3 4 1 5 1 2 1 2 3 2 3 1 3 1 4 1 4 1 2 4 1 2 3 1 3 1 3 4 2 ...
result:
ok orz (4645 test cases)
Test #3:
score: 0
Accepted
time: 16ms
memory: 6124kb
input:
2379 56 2 1 1 56 2 0 1 56 2 0 0 55 12 1 1 1 1 1 1 1 1 1 1 1 1 55 12 1 0 1 1 1 1 1 1 1 1 1 1 55 12 0 1 1 1 0 1 1 1 1 1 1 1 55 12 0 1 1 1 1 1 1 1 0 1 0 1 55 12 0 1 0 1 0 1 1 1 1 1 1 0 55 12 1 0 1 0 0 0 1 0 1 1 1 1 55 12 0 0 1 1 0 0 1 0 1 1 1 0 55 12 0 0 0 1 0 1 0 1 1 1 0 0 55 12 0 1 1 0 0 0 0 1 1 0 0 ...
output:
92 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 2 11 2 3 12 2 4 13 2 5 14 2 6 15 2 7 16 2 8 17 2 9 18 2 10 19 2 12 20 1 20 11 2 13 21 1 21 11 2 13 22 1 22 12 2 14 23 1 23 11 2 14 24 1 24 12 2 14 25 1 25 13 2 15 26 1 26 11 2 15 27 1 27 12 2 15 28 1 28 13 2 15 29 1 29 14 2 16 30 1 30 11 2 16...
result:
ok orz (2379 test cases)
Test #4:
score: 0
Accepted
time: 16ms
memory: 6148kb
input:
1244 73 3 1 1 1 87 3 1 1 1 60 4 1 1 0 0 72 4 0 1 1 1 84 4 0 0 0 0 100 2 1 1 64 2 1 0 81 3 1 1 1 101 6 1 1 0 1 0 0 66 6 1 0 1 1 0 1 59 2 1 1 68 6 1 1 0 0 0 0 87 6 1 1 1 1 1 1 105 4 0 1 0 0 104 3 1 1 1 94 6 1 1 0 0 0 1 91 5 1 1 1 1 1 63 3 1 0 0 100 5 0 0 0 0 0 70 4 1 1 1 1 61 5 0 0 0 0 1 104 2 0 1 94 ...
output:
98 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 2 9 2 3 10 2 4 11 2 5 12 2 6 13 2 7 14 2 8 15 2 9 16 3 10 17 3 11 18 3 12 19 3 13 20 3 14 21 3 15 22 3 17 23 1 23 24 2 24 16 3 18 25 1 25 26 2 26 16 3 18 27 1 27 28 2 28 17 3 19 29 1 29 30 2 30 16 3 19 31 1 31 32 2 32 17 3 19 33 1 33 34 2 34 18 3 20 35 1 ...
result:
ok orz (1244 test cases)
Test #5:
score: 0
Accepted
time: 18ms
memory: 6152kb
input:
739 105 2 0 0 105 2 1 0 105 2 1 1 105 3 0 0 0 105 3 0 0 1 105 3 0 1 1 105 3 1 1 1 105 4 0 0 0 0 105 4 0 1 0 0 105 4 0 1 1 0 105 4 1 0 1 1 105 4 1 1 1 1 106 2 0 0 106 2 0 1 106 2 1 1 106 3 0 0 0 106 3 1 0 0 106 3 0 1 1 106 3 1 1 1 106 4 0 0 0 0 106 4 0 0 0 1 106 4 1 0 1 0 106 4 0 1 1 1 106 4 1 1 1 1 ...
output:
208 1 2 1 2 1 2 1 3 1 3 1 2 1 4 1 4 1 2 1 5 1 5 1 2 1 6 1 6 1 2 1 7 1 7 1 2 1 8 1 8 1 2 1 9 1 9 1 2 1 10 1 10 1 2 1 11 1 11 1 2 1 12 1 12 1 2 1 13 1 13 1 2 1 14 1 14 1 2 1 15 1 15 1 2 1 16 1 16 1 2 1 17 1 17 1 2 1 18 1 18 1 2 1 19 1 19 1 2 1 20 1 20 1 2 1 21 1 21 1 2 1 22 1 22 1 2 1 23 1 23 1 2 1 24...
result:
ok orz (739 test cases)
Test #6:
score: 0
Accepted
time: 15ms
memory: 6188kb
input:
495 237 3 0 1 0 237 3 0 0 0 237 2 1 1 237 2 0 1 237 2 0 0 236 3 1 1 1 236 3 0 1 1 236 3 0 1 0 236 3 0 0 0 236 2 1 1 236 2 0 1 236 2 0 0 235 3 1 1 1 235 3 1 0 1 235 3 1 0 0 235 3 0 0 0 235 2 1 1 235 2 0 1 235 2 0 0 234 3 1 1 1 234 3 0 1 1 234 3 1 0 0 234 3 0 0 0 234 2 1 1 234 2 0 1 234 2 0 0 233 3 1 ...
output:
347 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 1 11 2 1 12 2 1 13 2 1 14 2 1 15 2 1 16 2 3 17 1 17 18 3 18 2 2 4 19 1 19 20 3 20 2 2 4 21 1 21 22 3 22 3 2 5 23 1 23 24 3 24 2 2 5 25 1 25 26 3 26 3 2 5 27 1 27 28 3 28 4 2 6 29 1 29 30 3 30 2 2 6 31 1 31 32 3 32 3 2 6 33 1 33 34 3 34 4 2 6...
result:
ok orz (495 test cases)
Test #7:
score: 0
Accepted
time: 21ms
memory: 6160kb
input:
339 259 2 1 1 270 2 1 0 348 2 0 0 336 2 0 1 275 2 1 1 279 2 0 1 340 2 1 1 283 2 0 0 292 2 0 0 327 2 1 1 316 2 0 0 328 2 0 0 244 2 1 1 302 2 0 0 264 2 0 0 291 2 1 1 266 2 0 1 320 2 0 1 317 2 1 0 336 2 0 0 310 2 0 0 240 2 0 0 345 2 0 0 292 2 1 1 267 2 1 1 340 2 1 0 291 2 0 1 312 2 1 1 269 2 1 1 278 2 ...
output:
474 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 2 23 2 3 24 2 4 25 2 5 26 2 6 27 2 7 28 2 8 29 2 9 30 2 10 31 2 11 32 2 12 33 2 13 34 2 14 35 2 15 36 2 16 37 2 17 38 2 18 39 2 19 40 2 20 41 2 21 42 2 22 43...
result:
ok orz (339 test cases)
Test #8:
score: 0
Accepted
time: 9ms
memory: 6464kb
input:
15 5529 5529 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
5529 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10 9 10 11 10 11 12 11 12 13 12 13 14 13 14 15 14 15 16 15 16 17 16 17 18 17 18 19 18 19 20 19 20 21 20 21 22 21 22 23 22 23 24 23 24 25 24 25 26 25 26 27 26 27 28 27 28 29 28 29 30 29 30 31 30 31 32 31 32 33 32 33 34 33 34 35 34 35 36 35 36 37 ...
result:
ok orz (15 test cases)
Test #9:
score: 0
Accepted
time: 11ms
memory: 6496kb
input:
35 2838 6 1 1 1 1 1 1 1516 73 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1974 7 1 1 1 1 1 1 1 2499 4 1 1 1 1 1520 4 1 1 1 1 2235 224 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
3365 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 2 35 2 3 36 2 4 37 2 5 38 2 6 39 2 7 40 2 8 41 2 9 42 2 10 43 2 11 44 2 ...
result:
ok orz (35 test cases)
Test #10:
score: 0
Accepted
time: 7ms
memory: 6568kb
input:
15 5017 4 1 1 1 1 5456 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4186 4 1 1 1 1 6624 23 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3667...
output:
6612 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 1 1 44 1 1 ...
result:
ok orz (15 test cases)
Test #11:
score: 0
Accepted
time: 7ms
memory: 6272kb
input:
35 2094 90 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 1 0 0 0 0 0 1 1931 82 1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 1...
output:
2114 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 2 9 5 3 10 5 4 11 5 5 12 5 6 13 5 7 14 5 8 15 5 9 16 10 10 17 10 11 18 10 12 19 10 13 20 10 14 21 10 15 22 10 16 23 13 17 24 13 18 25 13 19 26 13 20 27 13 21 28 13 22 29 13 23 30 16 24 31 16 25 32 16 26 33 16 27 34 16 28 35 16 29 36 16 30 37 20 31 38 20...
result:
ok orz (35 test cases)
Test #12:
score: 0
Accepted
time: 11ms
memory: 6312kb
input:
15 3844 3 0 1 0 4674 27 1 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 5623 91 0 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0 4276 340 0 1 0 1 1 0 0 1 1 1 1 1...
output:
5734 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 1 11 2 1 12 2 1 13 2 1 14 2 1 15 2 1 16 2 1 17 2 1 18 2 1 19 2 1 20 2 1 21 2 1 22 2 1 23 2 1 24 2 1 25 2 1 26 2 1 27 2 1 28 2 1 29 2 1 30 2 1 31 2 1 32 2 1 33 2 1 34 2 1 35 2 1 36 2 1 37 2 1 38 2 1 39 2 1 40 2 1 41 2 1 42 2 1 43 2 1 44 2 1 ...
result:
ok orz (15 test cases)
Test #13:
score: 0
Accepted
time: 12ms
memory: 6292kb
input:
35 2003 92 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 2282 24 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 1 1490 29 0 1 0 0 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 1...
output:
2023 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 2 8 3 3 9 3 4 10 3 5 11 3 6 12 3 7 13 3 8 14 10 9 15 10 10 16 10 11 17 10 12 18 10 13 19 10 14 20 16 15 21 16 16 22 16 17 23 16 18 24 16 19 25 16 20 26 20 21 27 20 22 28 20 23 29 20 24 30 20 25 31 20 26 32 22 27 33 22 28 34 22 29 35 22 30 36 22 31 37 22 32 38...
result:
ok orz (35 test cases)
Test #14:
score: 0
Accepted
time: 11ms
memory: 6404kb
input:
15 5107 312 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 ...
output:
5120 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 2 7 4 3 8 4 4 9 4 5 10 4 6 11 4 7 12 5 8 13 5 9 14 5 10 15 5 11 16 5 12 17 6 13 18 6 14 19 6 15 20 6 16 21 6 17 22 8 18 23 8 19 24 8 20 25 8 21 26 8 22 27 9 23 28 9 24 29 9 25 30 9 26 31 9 27 32 10 28 33 10 29 34 10 30 35 10 31 36 10 32 37 11 33 38 11 34 39 11 35 4...
result:
ok orz (15 test cases)
Test #15:
score: 0
Accepted
time: 15ms
memory: 6464kb
input:
1000 64 5 1 0 1 1 1 25 4 0 0 0 0 53 11 0 0 1 1 1 1 0 1 1 1 0 69 10 0 0 0 0 0 0 1 1 0 0 23 3 1 1 0 103 13 0 1 1 1 0 0 1 0 1 1 0 0 0 104 7 0 0 0 0 0 0 0 72 9 0 0 0 0 0 1 0 0 1 144 12 1 0 1 1 1 0 1 1 0 1 0 0 23 6 0 1 1 0 0 0 137 14 0 0 1 0 0 0 0 0 0 1 1 0 0 0 56 9 1 1 0 1 1 1 1 0 1 52 7 0 0 0 0 0 0 0 3...
output:
74 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 2 7 3 3 8 3 4 9 3 5 10 3 6 11 3 7 12 4 8 13 4 9 14 4 10 15 4 11 16 4 12 17 5 13 18 5 14 19 5 15 20 5 16 21 5 18 22 2 22 23 1 23 24 3 24 25 4 25 17 5 19 26 2 26 27 1 27 28 3 28 29 4 29 17 5 19 30 2 30 31 1 31 32 3 32 33 4 33 18 5 20 34 2 34 35 1 35 36 3 36 37 4 37 17 ...
result:
ok orz (1000 test cases)
Test #16:
score: 0
Accepted
time: 9ms
memory: 6504kb
input:
300 259 9 0 0 0 0 1 0 0 1 0 68 11 1 0 1 1 1 1 1 0 1 0 1 52 9 1 0 0 1 1 0 0 1 0 339 25 1 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0 871 34 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 0 0 1 152 8 0 1 1 0 0 1 0 1 199 7 1 1 1 1 1 1 1 74 9 1 1 0 0 0 1 1 1 0 258 30 0 0 1 0 0 1 1 1 0...
output:
289 1 2 5 1 3 5 1 4 5 1 5 5 1 6 5 1 7 5 1 8 5 1 9 5 2 10 8 3 11 8 4 12 8 5 13 8 6 14 8 7 15 8 8 16 8 9 17 8 11 18 1 18 19 2 19 20 3 20 21 4 21 22 6 22 23 7 23 24 9 24 25 5 25 10 8 12 26 1 26 27 2 27 28 3 28 29 4 29 30 6 30 31 7 31 32 9 32 33 5 33 10 8 12 34 1 34 35 2 35 36 3 36 37 4 37 38 6 38 39 7 ...
result:
ok orz (300 test cases)
Test #17:
score: 0
Accepted
time: 13ms
memory: 6260kb
input:
100 1046 22 1 0 0 1 0 0 0 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0 153 18 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 1 0 0 1068 30 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 326 20 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 927 28 0 1 1 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 2382 56 1 1 1 1 0 0 1 1...
output:
1091 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 2 12 4 3 13 4 4 14 4 5 15 4 6 16 4 7 17 4 8 18 4 9 19 4 10 20 4 11 21 4 12 22 9 13 23 9 14 24 9 15 25 9 16 26 9 17 27 9 18 28 9 19 29 9 20 30 9 21 31 9 22 32 10 23 33 10 24 34 10 25 35 10 26 36 10 27 37 10 28 38 10 29 39 10 30 40 10 ...
result:
ok orz (100 test cases)
Test #18:
score: 0
Accepted
time: 6ms
memory: 6212kb
input:
50 1661 20 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1602 45 0 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 124 7 0 1 0 1 1 1 1 2537 19 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 4030 93 1 0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0...
output:
1738 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 1 11 2 1 12 2 1 13 2 1 14 2 2 15 3 3 16 3 4 17 3 5 18 3 6 19 3 7 20 3 8 21 3 9 22 3 10 23 3 11 24 3 12 25 3 13 26 3 14 27 3 15 28 4 16 29 4 17 30 4 18 31 4 19 32 4 20 33 4 21 34 4 22 35 4 23 36 4 24 37 4 25 38 4 26 39 4 27 40 4 28 41 5 29 4...
result:
ok orz (50 test cases)
Test #19:
score: 0
Accepted
time: 13ms
memory: 6596kb
input:
20 7855 37 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 1 4327 92 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 4125 64 1 1 1 1 1 1 1 0...
output:
8058 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 2 22 3 3 23 3 4 24 3 5 25 3 6 26 3 7 27 3 8 28 3 9 29 3 10 30 3 11 31 3 12 32 3 13 33 3 14 34 3 15 35 3 16 36 3 17 37 3 18 38 3 19 39 3 20 40 3 21 41 3 22 42 4 23 ...
result:
ok orz (20 test cases)
Test #20:
score: 0
Accepted
time: 13ms
memory: 6332kb
input:
10 1446 13 1 0 1 0 0 0 0 0 0 0 0 0 0 19759 95 0 0 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 13321 134 0 0 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 ...
output:
1563 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 2 17 3 3 18 3 4 19 3 5 20 3 6 21 3 7 22 3 8 23 3 9 24 3 10 25 3 11 26 3 12 27 3 13 28 3 14 29 3 15 30 3 16 31 3 18 32 2 32 33 4 33 34 5 34 35 6 35 36 7 36 37 8 37 38 9 38 39 10 39 40 11 40 41 12 41 ...
result:
ok orz (10 test cases)
Test #21:
score: 0
Accepted
time: 10ms
memory: 7108kb
input:
3 41501 278 0 0 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 ...
output:
41643 1 2 3 1 3 3 1 4 3 1 5 3 1 6 3 1 7 3 1 8 3 1 9 3 1 10 3 1 11 3 1 12 3 1 13 3 1 14 3 1 15 3 1 16 3 1 17 3 1 18 3 2 19 5 3 20 5 4 21 5 5 22 5 6 23 5 7 24 5 8 25 5 9 26 5 10 27 5 11 28 5 12 29 5 13 30 5 14 31 5 15 32 5 16 33 5 17 34 5 18 35 5 19 36 6 20 37 6 21 38 6 22 39 6 23 40 6 24 41 6 25 42 6...
result:
ok orz (3 test cases)
Test #22:
score: 0
Accepted
time: 24ms
memory: 8976kb
input:
1 100000 2 0 0
output:
199998 1 2 1 2 1 2 1 3 1 3 1 2 1 4 1 4 1 2 1 5 1 5 1 2 1 6 1 6 1 2 1 7 1 7 1 2 1 8 1 8 1 2 1 9 1 9 1 2 1 10 1 10 1 2 1 11 1 11 1 2 1 12 1 12 1 2 1 13 1 13 1 2 1 14 1 14 1 2 1 15 1 15 1 2 1 16 1 16 1 2 1 17 1 17 1 2 1 18 1 18 1 2 1 19 1 19 1 2 1 20 1 20 1 2 1 21 1 21 1 2 1 22 1 22 1 2 1 23 1 23 1 2 1...
result:
ok orz (1 test case)
Test #23:
score: 0
Accepted
time: 20ms
memory: 8908kb
input:
1 100000 2 0 1
output:
199552 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 1 11 2 1 12 2 1 13 2 1 14 2 1 15 2 1 16 2 1 17 2 1 18 2 1 19 2 1 20 2 1 21 2 1 22 2 1 23 2 1 24 2 1 25 2 1 26 2 1 27 2 1 28 2 1 29 2 1 30 2 1 31 2 1 32 2 1 33 2 1 34 2 1 35 2 1 36 2 1 37 2 1 38 2 1 39 2 1 40 2 1 41 2 1 42 2 1 43 2 1 44 2 ...
result:
ok orz (1 test case)
Test #24:
score: 0
Accepted
time: 21ms
memory: 9704kb
input:
1 100000 2 1 1
output:
199108 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 1 1 44 1 ...
result:
ok orz (1 test case)
Test #25:
score: 0
Accepted
time: 12ms
memory: 7228kb
input:
1 100000 2 0 2
output:
99999 1 2 2 1 3 2 1 4 2 1 5 2 1 6 2 1 7 2 1 8 2 1 9 2 1 10 2 1 11 2 1 12 2 1 13 2 1 14 2 1 15 2 1 16 2 1 17 2 1 18 2 1 19 2 1 20 2 1 21 2 1 22 2 1 23 2 1 24 2 1 25 2 1 26 2 1 27 2 1 28 2 1 29 2 1 30 2 1 31 2 1 32 2 1 33 2 1 34 2 1 35 2 1 36 2 1 37 2 1 38 2 1 39 2 1 40 2 1 41 2 1 42 2 1 43 2 1 44 2 1...
result:
ok orz (1 test case)
Test #26:
score: 0
Accepted
time: 18ms
memory: 7700kb
input:
1 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 1000...
output:
99999 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 1 1 44 1 1...
result:
ok orz (1 test case)
Extra Test:
score: 0
Extra Test Passed