#include <bits/stdc++.h>
using namespace std;
int n, m;
int cost[1205][1205];
// Use:
// Constructor: Dinic dinic(n)
//
// add edges: dinic.addEdge(u, v, c)
//
// trace: for (auto e: dinic.E) {
// if (e.flow && e.cap) {
// cout << e.u << " " << e.v << " " << e.flow << endl;
// }
// }
//
// minCut: i from (0 to dinic.N - 1): dinic.d[i] != dinic.N + 1
struct Edge {
int u, v;
long long cap, flow;
Edge() {}
Edge(int u, int v, long long cap): u(u), v(v), cap(cap), flow(0) {}
};
struct Dinic {
int N;
vector<Edge> E;
vector<vector<int>> g;
vector<int> d, pt;
Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}
void addEdge(int u, int v, long long cap) {
if (u != v) {
E.emplace_back(Edge(u, v, cap));
g[u].emplace_back(E.size() - 1);
E.emplace_back(Edge(v, u, 0));
g[v].emplace_back(E.size() - 1);
}
}
bool bfs(int S, int T) {
queue<int> q({S});
fill(d.begin(), d.end(), N + 1);
d[S] = 0;
while(!q.empty()) {
int u = q.front(); q.pop();
if (u == T) break;
for (int k: g[u]) {
Edge &e = E[k];
if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
d[e.v] = d[e.u] + 1;
q.emplace(e.v);
}
}
}
return d[T] != N + 1;
}
long long dfs(int u, int T, long long flow = -1) {
if (u == T || flow == 0) return flow;
for (int &i = pt[u]; i < g[u].size(); ++i) {
Edge &e = E[g[u][i]];
Edge &oe = E[g[u][i]^1];
if (d[e.v] == d[e.u] + 1) {
long long amt = e.cap - e.flow;
if (flow != -1 && amt > flow) amt = flow;
if (long long pushed = dfs(e.v, T, amt)) {
e.flow += pushed;
oe.flow -= pushed;
return pushed;
}
}
}
return 0;
}
long long maxFlow(int S, int T) {
long long total = 0;
while (bfs(S, T)) {
fill(pt.begin(), pt.end(), 0);
while (long long flow = dfs(S, T))
total += flow;
}
return total;
}
};
void sub3() {
vector<int> match(n + 1);
auto solve = [&](int x) {
int source = 0;
int sink = n + m + 1;
Dinic dinic(sink + 1);
for (int i = 1; i <= n; i++) {
dinic.addEdge(source, i, 1);
}
for (int i = 1; i <= m; i++) {
dinic.addEdge(i + n, sink, 1);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (cost[i][j] >= x) {
dinic.addEdge(i, j + n, 1);
}
}
}
if (dinic.maxFlow(source, sink) == n) {
for (auto e: dinic.E) {
if (e.flow && e.cap) {
if (e.u > 0 && e.u <= n) {
match[e.u] = e.v - n;
}
}
}
return 1;
}
return 0;
};
int lower = 1, upper = 2000;
while (lower < upper) {
int mid = (lower + upper + 1) / 2;
if (solve(mid)) {
lower = mid;
}
else {
upper = mid - 1;
}
}
solve(lower);
for (int i = 1; i <= n; i++) {
cout << 1 << " " << match[i] << "\n";
}
}
struct Sub1 {
int dp[15][1 << 12];
int trace[15][1 << 12];
Sub1() {
memset(dp, 0, sizeof(dp));
memset(trace, -1, sizeof(trace));
}
void solve() {
dp[0][0] = 1e9;
for (int i = 1; i <= n; i++) {
for (int bit = 0; bit < (1 << m); bit++) {
for (int curBit = 1; curBit < (1 << m); curBit++) {
if (bit & (curBit)) continue;
int newBit = bit | curBit;
int curVal = 0;
for (int j = 1; j <= m; j++) {
if (curBit & (1 << (j - 1))) {
curVal += cost[i][j];
}
}
int newVal = min(dp[i - 1][bit], curVal);
if (newVal > dp[i][newBit]) {
dp[i][newBit] = newVal;
trace[i][newBit] = curBit;
}
}
}
}
int curBit = (1 << m) - 1;
vector<vector<int>> res;
for (int i = n; i >= 1; i--) {
int bit = trace[i][curBit];
curBit -= bit;
vector<int> cur;
for (int j = 0; j < m; j++) {
if (bit & (1 << j)) {
cur.push_back(j + 1);
}
}
res.push_back(cur);
}
reverse(res.begin(), res.end());
for (auto &v: res) {
cout << v.size() << " ";
for (auto i: v) cout << i << " ";
cout << "\n";
}
}
};
struct Data {
int first, second, index;
};
void sub2() {
vector<Data> v;
int sumAllB = 0;
for (int i = 1; i <= m; i++) {
v.push_back({cost[1][i], cost[2][i], i});
sumAllB += cost[2][i];
}
sort(v.begin(), v.end(), [](Data a, Data b) {
return a.first - a.second > b.first - b.second;
});
vector<int> resA, resB;
int finalRes = 0;
for (int z = 0; z <= 50000; z++) {
if (z) {
for (int i = 0; i + 1 < v.size(); i++) {
if (rand() % (z / 100 + 2) == 0) swap(v[i], v[i + 1]);
}
}
int sumB = sumAllB;
int res = 0, sumA = 0;
int index = -1;
for (int i = 0; i < m; i++) {
sumA += v[i].first;
sumB -= v[i].second;
if (res < min(sumA, sumB)) {
res = min(sumA, sumB);
index = i;
}
}
vector<int> tmpA, tmpB;
for (int i = 0; i < m; i++) {
if (i <= index) {
tmpA.push_back(v[i].index);
}
else {
tmpB.push_back(v[i].index);
}
}
if (res > finalRes) {
resA = tmpA;
resB = tmpB;
finalRes = res;
}
}
sort(resA.begin(), resA.end());
sort(resB.begin(), resB.end());
cout << resA.size() << " ";
for (auto i: resA) cout << i << " ";
cout << "\n";
cout << resB.size() << " ";
for (auto i: resB) cout << i << " ";
cout << "\n";
}
int main() {
srand(time(0));
// freopen("input.txt", "r", stdin);
// freopen("bonus.inp", "r", stdin);
// freopen("bonus.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> cost[i][j];
}
}
if (m <= 12 && n <= 12) {
Sub1().solve();
}
else if (m == n) {
sub3();
}
else {
sub2();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLCBtOwppbnQgY29zdFsxMjA1XVsxMjA1XTsKCi8vIFVzZToKLy8gQ29uc3RydWN0b3I6IERpbmljIGRpbmljKG4pCi8vIAovLyBhZGQgZWRnZXM6IGRpbmljLmFkZEVkZ2UodSwgdiwgYykKLy8gCi8vIHRyYWNlOiBmb3IgKGF1dG8gZTogZGluaWMuRSkgewovLyAgaWYgKGUuZmxvdyAmJiBlLmNhcCkgewovLyAgICAgIGNvdXQgPDwgZS51IDw8ICIgIiA8PCBlLnYgPDwgIiAiIDw8IGUuZmxvdyA8PCBlbmRsOwovLyAgfQovLyB9Ci8vIAovLyBtaW5DdXQ6IGkgZnJvbSAoMCB0byBkaW5pYy5OIC0gMSk6IGRpbmljLmRbaV0gIT0gZGluaWMuTiArIDEKc3RydWN0IEVkZ2UgewogICAgaW50IHUsIHY7CiAgICBsb25nIGxvbmcgY2FwLCBmbG93OwogICAgRWRnZSgpIHt9CiAgICBFZGdlKGludCB1LCBpbnQgdiwgbG9uZyBsb25nIGNhcCk6IHUodSksIHYodiksIGNhcChjYXApLCBmbG93KDApIHt9Cn07CgpzdHJ1Y3QgRGluaWMgewogICAgaW50IE47CiAgICB2ZWN0b3I8RWRnZT4gRTsKICAgIHZlY3Rvcjx2ZWN0b3I8aW50Pj4gZzsKICAgIHZlY3RvcjxpbnQ+IGQsIHB0OwogICAgRGluaWMoaW50IE4pOiBOKE4pLCBFKDApLCBnKE4pLCBkKE4pLCBwdChOKSB7fQogICAgdm9pZCBhZGRFZGdlKGludCB1LCBpbnQgdiwgbG9uZyBsb25nIGNhcCkgewogICAgICAgIGlmICh1ICE9IHYpIHsKICAgICAgICAgICAgRS5lbXBsYWNlX2JhY2soRWRnZSh1LCB2LCBjYXApKTsKICAgICAgICAgICAgZ1t1XS5lbXBsYWNlX2JhY2soRS5zaXplKCkgLSAxKTsKICAgICAgICAgICAgRS5lbXBsYWNlX2JhY2soRWRnZSh2LCB1LCAwKSk7CiAgICAgICAgICAgIGdbdl0uZW1wbGFjZV9iYWNrKEUuc2l6ZSgpIC0gMSk7CiAgICAgICAgfQogICAgfQogICAgYm9vbCBiZnMoaW50IFMsIGludCBUKSB7CiAgICAgICAgcXVldWU8aW50PiBxKHtTfSk7CiAgICAgICAgZmlsbChkLmJlZ2luKCksIGQuZW5kKCksIE4gKyAxKTsKICAgICAgICBkW1NdID0gMDsKICAgICAgICB3aGlsZSghcS5lbXB0eSgpKSB7CiAgICAgICAgICAgIGludCB1ID0gcS5mcm9udCgpOyBxLnBvcCgpOwogICAgICAgICAgICBpZiAodSA9PSBUKSBicmVhazsKICAgICAgICAgICAgZm9yIChpbnQgazogZ1t1XSkgewogICAgICAgICAgICAgICAgRWRnZSAmZSA9IEVba107CiAgICAgICAgICAgICAgICBpZiAoZS5mbG93IDwgZS5jYXAgJiYgZFtlLnZdID4gZFtlLnVdICsgMSkgewogICAgICAgICAgICAgICAgICAgIGRbZS52XSA9IGRbZS51XSArIDE7CiAgICAgICAgICAgICAgICAgICAgcS5lbXBsYWNlKGUudik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGRbVF0gIT0gTiArIDE7CiAgICB9CiAgICBsb25nIGxvbmcgZGZzKGludCB1LCBpbnQgVCwgbG9uZyBsb25nIGZsb3cgPSAtMSkgewogICAgICAgIGlmICh1ID09IFQgfHwgZmxvdyA9PSAwKSByZXR1cm4gZmxvdzsKICAgICAgICBmb3IgKGludCAmaSA9IHB0W3VdOyBpIDwgZ1t1XS5zaXplKCk7ICsraSkgewogICAgICAgICAgICBFZGdlICZlID0gRVtnW3VdW2ldXTsKICAgICAgICAgICAgRWRnZSAmb2UgPSBFW2dbdV1baV1eMV07CiAgICAgICAgICAgIGlmIChkW2Uudl0gPT0gZFtlLnVdICsgMSkgewogICAgICAgICAgICAgICAgbG9uZyBsb25nIGFtdCA9IGUuY2FwIC0gZS5mbG93OwogICAgICAgICAgICAgICAgaWYgKGZsb3cgIT0gLTEgJiYgYW10ID4gZmxvdykgYW10ID0gZmxvdzsKICAgICAgICAgICAgICAgIGlmIChsb25nIGxvbmcgcHVzaGVkID0gZGZzKGUudiwgVCwgYW10KSkgewogICAgICAgICAgICAgICAgICAgIGUuZmxvdyArPSBwdXNoZWQ7CiAgICAgICAgICAgICAgICAgICAgb2UuZmxvdyAtPSBwdXNoZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHB1c2hlZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGxvbmcgbG9uZyBtYXhGbG93KGludCBTLCBpbnQgVCkgewogICAgICAgIGxvbmcgbG9uZyB0b3RhbCA9IDA7CiAgICAgICAgd2hpbGUgKGJmcyhTLCBUKSkgewogICAgICAgICAgICBmaWxsKHB0LmJlZ2luKCksIHB0LmVuZCgpLCAwKTsKICAgICAgICAgICAgd2hpbGUgKGxvbmcgbG9uZyBmbG93ID0gZGZzKFMsIFQpKQogICAgICAgICAgICAgICAgdG90YWwgKz0gZmxvdzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRvdGFsOwogICAgfQp9OwoKCnZvaWQgc3ViMygpIHsKICAgIHZlY3RvcjxpbnQ+IG1hdGNoKG4gKyAxKTsKCiAgICBhdXRvIHNvbHZlID0gWyZdKGludCB4KSB7CiAgICAgICAgaW50IHNvdXJjZSA9IDA7CiAgICAgICAgaW50IHNpbmsgPSBuICsgbSArIDE7CiAgICAgICAgRGluaWMgZGluaWMoc2luayArIDEpOwoKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgZGluaWMuYWRkRWRnZShzb3VyY2UsIGksIDEpOwogICAgICAgIH0KCiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbTsgaSsrKSB7CiAgICAgICAgICAgIGRpbmljLmFkZEVkZ2UoaSArIG4sIHNpbmssIDEpOwogICAgICAgIH0KCiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7CiAgICAgICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG07IGorKykgewogICAgICAgICAgICAgICAgaWYgKGNvc3RbaV1bal0gPj0geCkgewogICAgICAgICAgICAgICAgICAgIGRpbmljLmFkZEVkZ2UoaSwgaiArIG4sIDEpOwogICAgICAgICAgICAgICAgfSAKICAgICAgICAgICAgfQogICAgICAgIH0KCgogICAgICAgIGlmIChkaW5pYy5tYXhGbG93KHNvdXJjZSwgc2luaykgPT0gbikgewogICAgICAgICAgICBmb3IgKGF1dG8gZTogZGluaWMuRSkgewogICAgICAgICAgICAgICAgaWYgKGUuZmxvdyAmJiBlLmNhcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChlLnUgPiAwICYmIGUudSA8PSBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hdGNoW2UudV0gPSBlLnYgLSBuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIDA7CiAgICB9OwoKICAgIGludCBsb3dlciA9IDEsIHVwcGVyID0gMjAwMDsKICAgIHdoaWxlIChsb3dlciA8IHVwcGVyKSB7CiAgICAgICAgaW50IG1pZCA9IChsb3dlciArIHVwcGVyICsgMSkgLyAyOwogICAgICAgIGlmIChzb2x2ZShtaWQpKSB7CiAgICAgICAgICAgIGxvd2VyID0gbWlkOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgdXBwZXIgPSBtaWQgLSAxOwogICAgICAgIH0KICAgIH0KICAgIHNvbHZlKGxvd2VyKTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewogICAgICAgIGNvdXQgPDwgMSA8PCAiICIgPDwgbWF0Y2hbaV0gPDwgIlxuIjsKICAgIH0KfQoKc3RydWN0IFN1YjEgewogICAgaW50IGRwWzE1XVsxIDw8IDEyXTsKICAgIGludCB0cmFjZVsxNV1bMSA8PCAxMl07CiAgICBTdWIxKCkgewogICAgICAgIG1lbXNldChkcCwgMCwgc2l6ZW9mKGRwKSk7CiAgICAgICAgbWVtc2V0KHRyYWNlLCAtMSwgc2l6ZW9mKHRyYWNlKSk7CiAgICB9CgogICAgdm9pZCBzb2x2ZSgpIHsKICAgICAgICBkcFswXVswXSA9IDFlOTsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgZm9yIChpbnQgYml0ID0gMDsgYml0IDwgKDEgPDwgbSk7IGJpdCsrKSB7CiAgICAgICAgICAgICAgICBmb3IgKGludCBjdXJCaXQgPSAxOyBjdXJCaXQgPCAoMSA8PCBtKTsgY3VyQml0KyspIHsKICAgICAgICAgICAgICAgICAgICBpZiAoYml0ICYgKGN1ckJpdCkpIGNvbnRpbnVlOwoKCiAgICAgICAgICAgICAgICAgICAgaW50IG5ld0JpdCA9IGJpdCB8IGN1ckJpdDsKCiAgICAgICAgICAgICAgICAgICAgaW50IGN1clZhbCA9IDA7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPD0gbTsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJCaXQgJiAoMSA8PCAoaiAtIDEpKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VyVmFsICs9IGNvc3RbaV1bal07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIGludCBuZXdWYWwgPSBtaW4oZHBbaSAtIDFdW2JpdF0sIGN1clZhbCk7CgogICAgICAgICAgICAgICAgICAgIGlmIChuZXdWYWwgPiBkcFtpXVtuZXdCaXRdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRwW2ldW25ld0JpdF0gPSBuZXdWYWw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNlW2ldW25ld0JpdF0gPSBjdXJCaXQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBpbnQgY3VyQml0ID0gKDEgPDwgbSkgLSAxOwogICAgICAgIHZlY3Rvcjx2ZWN0b3I8aW50Pj4gcmVzOwogICAgICAgIGZvciAoaW50IGkgPSBuOyBpID49IDE7IGktLSkgewogICAgICAgICAgICBpbnQgYml0ID0gdHJhY2VbaV1bY3VyQml0XTsKICAgICAgICAgICAgY3VyQml0IC09IGJpdDsKCiAgICAgICAgICAgIHZlY3RvcjxpbnQ+IGN1cjsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBtOyBqKyspIHsKICAgICAgICAgICAgICAgIGlmIChiaXQgJiAoMSA8PCBqKSkgewogICAgICAgICAgICAgICAgICAgIGN1ci5wdXNoX2JhY2soaiArIDEpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHJlcy5wdXNoX2JhY2soY3VyKTsKICAgICAgICB9CiAgICAgICAgcmV2ZXJzZShyZXMuYmVnaW4oKSwgcmVzLmVuZCgpKTsKICAgICAgICBmb3IgKGF1dG8gJnY6IHJlcykgewogICAgICAgICAgICBjb3V0IDw8IHYuc2l6ZSgpIDw8ICIgIjsKICAgICAgICAgICAgZm9yIChhdXRvIGk6IHYpIGNvdXQgPDwgaSA8PCAiICI7CiAgICAgICAgICAgIGNvdXQgPDwgIlxuIjsKICAgICAgICB9CiAgICB9Cn07CgpzdHJ1Y3QgRGF0YSB7CiAgICBpbnQgZmlyc3QsIHNlY29uZCwgaW5kZXg7Cn07Cgp2b2lkIHN1YjIoKSB7CiAgICB2ZWN0b3I8RGF0YT4gdjsKCiAgICBpbnQgc3VtQWxsQiA9IDA7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBtOyBpKyspIHsKICAgICAgICB2LnB1c2hfYmFjayh7Y29zdFsxXVtpXSwgY29zdFsyXVtpXSwgaX0pOwogICAgICAgIHN1bUFsbEIgKz0gY29zdFsyXVtpXTsKICAgIH0KICAgIHNvcnQodi5iZWdpbigpLCB2LmVuZCgpLCBbXShEYXRhIGEsIERhdGEgYikgewogICAgICAgIHJldHVybiBhLmZpcnN0IC0gYS5zZWNvbmQgPiBiLmZpcnN0IC0gYi5zZWNvbmQ7CiAgICB9KTsKCiAgICB2ZWN0b3I8aW50PiByZXNBLCByZXNCOwogICAgaW50IGZpbmFsUmVzID0gMDsKCiAgICBmb3IgKGludCB6ID0gMDsgeiA8PSA1MDAwMDsgeisrKSB7CgogICAgICAgIGlmICh6KSB7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpICsgMSA8IHYuc2l6ZSgpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChyYW5kKCkgJSAoeiAvIDEwMCArIDIpID09IDApIHN3YXAodltpXSwgdltpICsgMV0pOyAKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpbnQgc3VtQiA9IHN1bUFsbEI7CiAgICAgICAgaW50IHJlcyA9IDAsIHN1bUEgPSAwOwogICAgICAgIGludCBpbmRleCA9IC0xOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgaSsrKSB7CiAgICAgICAgICAgIHN1bUEgKz0gdltpXS5maXJzdDsKICAgICAgICAgICAgc3VtQiAtPSB2W2ldLnNlY29uZDsKICAgICAgICAgICAgaWYgKHJlcyA8IG1pbihzdW1BLCBzdW1CKSkgewogICAgICAgICAgICAgICAgcmVzID0gbWluKHN1bUEsIHN1bUIpOwogICAgICAgICAgICAgICAgaW5kZXggPSBpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZlY3RvcjxpbnQ+IHRtcEEsIHRtcEI7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBtOyBpKyspIHsKICAgICAgICAgICAgaWYgKGkgPD0gaW5kZXgpIHsKICAgICAgICAgICAgICAgIHRtcEEucHVzaF9iYWNrKHZbaV0uaW5kZXgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgdG1wQi5wdXNoX2JhY2sodltpXS5pbmRleCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmIChyZXMgPiBmaW5hbFJlcykgewogICAgICAgICAgICByZXNBID0gdG1wQTsKICAgICAgICAgICAgcmVzQiA9IHRtcEI7CiAgICAgICAgICAgIGZpbmFsUmVzID0gcmVzOwogICAgICAgIH0KICAgIH0KCiAgICBzb3J0KHJlc0EuYmVnaW4oKSwgcmVzQS5lbmQoKSk7CiAgICBzb3J0KHJlc0IuYmVnaW4oKSwgcmVzQi5lbmQoKSk7CgogICAgY291dCA8PCByZXNBLnNpemUoKSA8PCAiICI7CiAgICBmb3IgKGF1dG8gaTogcmVzQSkgY291dCA8PCBpIDw8ICIgIjsgCiAgICBjb3V0IDw8ICJcbiI7CiAgICAKICAgIGNvdXQgPDwgcmVzQi5zaXplKCkgPDwgIiAiOwogICAgZm9yIChhdXRvIGk6IHJlc0IpIGNvdXQgPDwgaSA8PCAiICI7CiAgICBjb3V0IDw8ICJcbiI7Cn0KCmludCBtYWluKCkgewogICAgc3JhbmQodGltZSgwKSk7CiAgICAvLyBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgIC8vIGZyZW9wZW4oImJvbnVzLmlucCIsICJyIiwgc3RkaW4pOwogICAgLy8gZnJlb3BlbigiYm9udXMub3V0IiwgInciLCBzdGRvdXQpOwogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKE5VTEwpOwoKICAgIGNpbiA+PiBuID4+IG07CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyBqKyspIHsKICAgICAgICAgICAgY2luID4+IGNvc3RbaV1bal07CiAgICAgICAgfQogICAgfQoKICAgIGlmIChtIDw9IDEyICYmIG4gPD0gMTIpIHsKICAgICAgICBTdWIxKCkuc29sdmUoKTsKICAgIH0KICAgIGVsc2UgaWYgKG0gPT0gbikgewogICAgICAgIHN1YjMoKTsKICAgIH0KICAgIGVsc2UgewogICAgICAgIHN1YjIoKTsKICAgIH0KCiAgICAKCiAgICByZXR1cm4gMDsKfQo=
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
^
Main.java:3: error: class, interface, or enum expected
int n, m;
^
Main.java:4: error: class, interface, or enum expected
int cost[1205][1205];
^
Main.java:18: error: class, interface, or enum expected
struct Edge {
^
Main.java:20: error: class, interface, or enum expected
long long cap, flow;
^
Main.java:21: error: class, interface, or enum expected
Edge() {}
^
Main.java:25: error: class, interface, or enum expected
struct Dinic {
^
Main.java:27: error: class, interface, or enum expected
vector<Edge> E;
^
Main.java:28: error: class, interface, or enum expected
vector<vector<int>> g;
^
Main.java:29: error: class, interface, or enum expected
vector<int> d, pt;
^
Main.java:30: error: class, interface, or enum expected
Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}
^
Main.java:34: error: class, interface, or enum expected
g[u].emplace_back(E.size() - 1);
^
Main.java:35: error: class, interface, or enum expected
E.emplace_back(Edge(v, u, 0));
^
Main.java:36: error: class, interface, or enum expected
g[v].emplace_back(E.size() - 1);
^
Main.java:37: error: class, interface, or enum expected
}
^
Main.java:41: error: class, interface, or enum expected
fill(d.begin(), d.end(), N + 1);
^
Main.java:42: error: class, interface, or enum expected
d[S] = 0;
^
Main.java:43: error: class, interface, or enum expected
while(!q.empty()) {
^
Main.java:44: error: class, interface, or enum expected
int u = q.front(); q.pop();
^
Main.java:45: error: class, interface, or enum expected
if (u == T) break;
^
Main.java:46: error: class, interface, or enum expected
for (int k: g[u]) {
^
Main.java:48: error: class, interface, or enum expected
if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
^
Main.java:50: error: class, interface, or enum expected
q.emplace(e.v);
^
Main.java:51: error: class, interface, or enum expected
}
^
Main.java:55: error: class, interface, or enum expected
}
^
Main.java:58: error: class, interface, or enum expected
for (int &i = pt[u]; i < g[u].size(); ++i) {
^
Main.java:58: error: class, interface, or enum expected
for (int &i = pt[u]; i < g[u].size(); ++i) {
^
Main.java:58: error: class, interface, or enum expected
for (int &i = pt[u]; i < g[u].size(); ++i) {
^
Main.java:60: error: class, interface, or enum expected
Edge &oe = E[g[u][i]^1];
^
Main.java:61: error: class, interface, or enum expected
if (d[e.v] == d[e.u] + 1) {
^
Main.java:63: error: class, interface, or enum expected
if (flow != -1 && amt > flow) amt = flow;
^
Main.java:64: error: class, interface, or enum expected
if (long long pushed = dfs(e.v, T, amt)) {
^
Main.java:66: error: class, interface, or enum expected
oe.flow -= pushed;
^
Main.java:67: error: class, interface, or enum expected
return pushed;
^
Main.java:68: error: class, interface, or enum expected
}
^
Main.java:72: error: class, interface, or enum expected
}
^
Main.java:75: error: class, interface, or enum expected
while (bfs(S, T)) {
^
Main.java:77: error: class, interface, or enum expected
while (long long flow = dfs(S, T))
^
Main.java:79: error: class, interface, or enum expected
}
^
Main.java:81: error: class, interface, or enum expected
}
^
Main.java:85: error: class, interface, or enum expected
void sub3() {
^
Main.java:88: error: class, interface, or enum expected
auto solve = [&](int x) {
^
Main.java:90: error: class, interface, or enum expected
int sink = n + m + 1;
^
Main.java:91: error: class, interface, or enum expected
Dinic dinic(sink + 1);
^
Main.java:93: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:93: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:93: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:95: error: class, interface, or enum expected
}
^
Main.java:97: error: class, interface, or enum expected
for (int i = 1; i <= m; i++) {
^
Main.java:97: error: class, interface, or enum expected
for (int i = 1; i <= m; i++) {
^
Main.java:99: error: class, interface, or enum expected
}
^
Main.java:101: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:101: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:102: error: class, interface, or enum expected
for (int j = 1; j <= m; j++) {
^
Main.java:102: error: class, interface, or enum expected
for (int j = 1; j <= m; j++) {
^
Main.java:105: error: class, interface, or enum expected
}
^
Main.java:115: error: class, interface, or enum expected
}
^
Main.java:119: error: class, interface, or enum expected
}
^
Main.java:121: error: class, interface, or enum expected
};
^
Main.java:123: error: class, interface, or enum expected
int lower = 1, upper = 2000;
^
Main.java:124: error: class, interface, or enum expected
while (lower < upper) {
^
Main.java:126: error: class, interface, or enum expected
if (solve(mid)) {
^
Main.java:128: error: class, interface, or enum expected
}
^
Main.java:131: error: class, interface, or enum expected
}
^
Main.java:134: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:134: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:134: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:136: error: class, interface, or enum expected
}
^
Main.java:141: error: class, interface, or enum expected
int trace[15][1 << 12];
^
Main.java:142: error: class, interface, or enum expected
Sub1() {
^
Main.java:144: error: class, interface, or enum expected
memset(trace, -1, sizeof(trace));
^
Main.java:145: error: class, interface, or enum expected
}
^
Main.java:149: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:149: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:149: error: class, interface, or enum expected
for (int i = 1; i <= n; i++) {
^
Main.java:150: error: class, interface, or enum expected
for (int bit = 0; bit < (1 << m); bit++) {
^
Main.java:150: error: class, interface, or enum expected
for (int bit = 0; bit < (1 << m); bit++) {
^
Main.java:151: error: class, interface, or enum expected
for (int curBit = 1; curBit < (1 << m); curBit++) {
^
Main.java:151: error: class, interface, or enum expected
for (int curBit = 1; curBit < (1 << m); curBit++) {
^
Main.java:155: error: class, interface, or enum expected
int newBit = bit | curBit;
^
Main.java:157: error: class, interface, or enum expected
int curVal = 0;
^
Main.java:158: error: class, interface, or enum expected
for (int j = 1; j <= m; j++) {
^
Main.java:158: error: class, interface, or enum expected
for (int j = 1; j <= m; j++) {
^
Main.java:158: error: class, interface, or enum expected
for (int j = 1; j <= m; j++) {
^
Main.java:161: error: class, interface, or enum expected
}
^
Main.java:166: error: class, interface, or enum expected
if (newVal > dp[i][newBit]) {
^
Main.java:168: error: class, interface, or enum expected
trace[i][newBit] = curBit;
^
Main.java:169: error: class, interface, or enum expected
}
^
Main.java:175: error: class, interface, or enum expected
vector<vector<int>> res;
^
Main.java:176: error: class, interface, or enum expected
for (int i = n; i >= 1; i--) {
^
Main.java:176: error: class, interface, or enum expected
for (int i = n; i >= 1; i--) {
^
Main.java:176: error: class, interface, or enum expected
for (int i = n; i >= 1; i--) {
^
Main.java:178: error: class, interface, or enum expected
curBit -= bit;
^
Main.java:180: error: class, interface, or enum expected
vector<int> cur;
^
Main.java:181: error: class, interface, or enum expected
for (int j = 0; j < m; j++) {
^
Main.java:181: error: class, interface, or enum expected
for (int j = 0; j < m; j++) {
^
Main.java:181: error: class, interface, or enum expected
for (int j = 0; j < m; j++) {
^
Main.java:184: error: class, interface, or enum expected
}
^
Main.java:187: error: class, interface, or enum expected
}
^
100 errors