#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;
vvi asked(500,vi(500,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;
vi visited(500,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});
}
}
add_or(check);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1312 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1368 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
1 ms |
1372 KB |
Output is correct |
17 |
Correct |
1 ms |
1372 KB |
Output is correct |
18 |
Correct |
1 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1312 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1368 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
1 ms |
1372 KB |
Output is correct |
17 |
Correct |
1 ms |
1372 KB |
Output is correct |
18 |
Correct |
1 ms |
1368 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
1 ms |
1384 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
1 ms |
1372 KB |
Output is correct |
24 |
Correct |
2 ms |
1372 KB |
Output is correct |
25 |
Correct |
3 ms |
1372 KB |
Output is correct |
26 |
Correct |
3 ms |
1372 KB |
Output is correct |
27 |
Correct |
3 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1312 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1368 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
1 ms |
1372 KB |
Output is correct |
17 |
Correct |
1 ms |
1372 KB |
Output is correct |
18 |
Correct |
1 ms |
1368 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
1 ms |
1384 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
1 ms |
1372 KB |
Output is correct |
24 |
Correct |
2 ms |
1372 KB |
Output is correct |
25 |
Correct |
3 ms |
1372 KB |
Output is correct |
26 |
Correct |
3 ms |
1372 KB |
Output is correct |
27 |
Correct |
3 ms |
1372 KB |
Output is correct |
28 |
Runtime error |
5 ms |
2652 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1312 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1368 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
1 ms |
1372 KB |
Output is correct |
17 |
Correct |
1 ms |
1372 KB |
Output is correct |
18 |
Correct |
1 ms |
1368 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
1 ms |
1384 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
1 ms |
1372 KB |
Output is correct |
24 |
Correct |
2 ms |
1372 KB |
Output is correct |
25 |
Correct |
3 ms |
1372 KB |
Output is correct |
26 |
Correct |
3 ms |
1372 KB |
Output is correct |
27 |
Correct |
3 ms |
1372 KB |
Output is correct |
28 |
Runtime error |
5 ms |
2652 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
2 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1444 KB |
Output is correct |
4 |
Correct |
2 ms |
1372 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
2 ms |
1372 KB |
Output is correct |
7 |
Correct |
2 ms |
1372 KB |
Output is correct |
8 |
Correct |
2 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1368 KB |
Output is correct |
11 |
Correct |
2 ms |
1368 KB |
Output is correct |
12 |
Correct |
2 ms |
1368 KB |
Output is correct |
13 |
Correct |
2 ms |
1368 KB |
Output is correct |
14 |
Correct |
2 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
2 ms |
1372 KB |
Output is correct |
17 |
Correct |
2 ms |
1372 KB |
Output is correct |
18 |
Correct |
2 ms |
1368 KB |
Output is correct |
19 |
Correct |
2 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
1 ms |
1372 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Runtime error |
2 ms |
2476 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2904 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1312 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1368 KB |
Output is correct |
13 |
Correct |
1 ms |
1368 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
1 ms |
1372 KB |
Output is correct |
16 |
Correct |
1 ms |
1372 KB |
Output is correct |
17 |
Correct |
1 ms |
1372 KB |
Output is correct |
18 |
Correct |
1 ms |
1368 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
1 ms |
1384 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
1 ms |
1372 KB |
Output is correct |
24 |
Correct |
2 ms |
1372 KB |
Output is correct |
25 |
Correct |
3 ms |
1372 KB |
Output is correct |
26 |
Correct |
3 ms |
1372 KB |
Output is correct |
27 |
Correct |
3 ms |
1372 KB |
Output is correct |
28 |
Runtime error |
5 ms |
2652 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |