#include "vision.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "Ofast")
#define ll long long
#define se second
#define fi first
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 5e5+100;
const int MAXA = 2e5+10;
const int SQRT = 450;
const ll INF = 2e9;
const int MOD = 998244353;
const int LOG = 60;
ll sum(auto a, auto b){
ll te = a+MOD+b;
for(; te >= MOD; ) te -= MOD;
return te;
}
void chsum(int &a, auto b){ a = sum(a,b); }
ll mul(auto a, auto b){ return 1ll*a*b%MOD; }
void chmul(auto &a, auto b){ a = mul(a,b); }
void chmn(auto &a, auto b){ a = min(a, b); }
void chmx(auto &a, auto b){ a = max(a, b); }
int h, w, k;
int row, col, r[MAXN], c[MAXN];
void construct_network(int H, int W, int K) {
h = H; w = W; k = K;
// bikin per row, jarak row
row = h*w;
for(int i=0; i<h; i++){
vector<int> vec;
for(int j=0; j<w; j++) vec.pb(i*w+j);
int las = add_or(vec);
}
for(int jar=1; jar<=h-1; jar++){
vector<int> mas;
for(int j=0; j+jar<h; j++){
vector<int> vec = {row+j, row+j+jar}; // gabungan row
mas.pb(add_and(vec));
}
// for(auto in : mas) cout << in << "in\n";
r[jar] = add_or(mas); // hasil jaraknya di sini
// cout << r[jar] << " r jar\n";
}
if(h-1 >= 1){
// cout << " masuk\n";
vector<int> rows;
for(int jar=1; jar<=h-1; jar++){
rows.pb(r[jar]);
// cout <<jar << ' '<< r[jar] << " r jar\n";
}
int las = add_or(rows);
r[0] = add_not(las);
} else {
//r[0] harus 1
vector<int> rows;
for(int rr=0; rr<h; rr++) rows.pb(rr+row);
r[0] = add_or(rows);
}
// per col, jarak colnya
col = -1;
for(int i=0; i<w; i++){
vector<int> vec;
for(int j=0; j<h; j++) vec.pb(j*w+i);
int las = add_or(vec);
if(col == -1) col = las;
}
// cout << col << ' ' << h*w <<' ' <<" col\n";
for(int jar=1; jar<=w-1; jar++){
vector<int> mas;
for(int j=0; j+jar<w; j++){
vector<int> vec = {col+j, col+j+jar}; // ambil gabungan col
mas.pb(add_and(vec));
}
c[jar] = add_or(mas); // hasil jaraknya di sini
}
if(w-1 >= 1){
vector<int> cols;
for(int jar=1; jar<=w-1; jar++) cols.pb(c[jar]);
int las = add_or(cols);
c[0] = add_not(las);
} else {
//c[0] harus 1
vector<int> cols;
for(int rr=0; rr<w; rr++) cols.pb(rr+col);
c[0] = add_or(cols);
}
// for(int i=0; i<=h-1; i++) cout << i << ' ' << r[i] << " r\n";
// for(int i=0; i<=w-1; i++) cout << i << ' ' << c[i] << " c\n";
// add jadi k ga
vector<int> idx;
for(int i=0; i<=min(k, h-1); i++){
for(int j=0; j<=min(k, w-1); j++){
if(i+j != k) continue;
vector<int> vec = {r[i], c[j]};
idx.pb(add_and(vec));
}
}
add_or(idx);
}
| # | 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... |
| # | 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... |