#include "vision.h"
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
// #include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
vector<vector<bool>> asked(400002,vector<bool>(400002,0));
vi check;
int K,H,W;
int convert(pi a){return (W*a.F)+a.S;}
void dfs(pi start){
priority_queue<pair<int,pi>> arr;
vector<bool> visited(400002,0);
arr.push({0,start});
int i = convert(start);
while(!arr.empty()){
int dist = -arr.top().F;
pi node = arr.top().S;
int j = convert(node);
arr.pop();
if(visited[j])continue;
visited[j] = 1;
if(dist == K){
// cout << start.F << "," << start.S << " | " << node.F << "," << node.S << " " << dist << endl;
if(!asked[i][j]){
asked[i][j] = 1;
asked[j][i] = 1;
vi q = {i,j};
int a = add_and(q);
// cout << a << endl;
check.pb(a);
}
}else if(dist < K){
if(node.F < H-1){
node.F++;
arr.push({-dist-1,node});
node.F--;
}
if(node.F >= 1){
node.F--;
arr.push({-dist-1,node});
node.F++;
}
if(node.S >= 1){
node.S--;
arr.push({-dist-1,node});
node.S++;
}
if(node.S < W-1){
node.S++;
arr.push({-dist-1,node});
node.S--;
}
}
}
}
void construct_network(int H_, int W_, int K_) {
H = H_;W = W_;K = K_;
FOR(i,0,H){
FOR(j,0,W){
dfs({i,j});
}
}
// dfs({0,0});
add_or(check);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
457 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
457 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
457 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
457 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
460 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
475 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
461 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
457 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |