#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
// #define int long long
typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7 ;
const int N = 10000010 ;
map<pair<int , int> , int > mp , use;
vector<pair<int,int>> v[410] ;
int d[222][222] ;
void construct_network(int H, int W, int K) {
vector<int> Ns , f;
for(int i = 0 ; i < H ; ++i){
for(int j = 0 ; j < W ; ++j){
for(int l = 0 ; l <= K ; l++){
int u = K - l ;
int nx = i + l , ny = j + u ;
int vl = i * W + j , vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
mp[{vl , vl1}] = 1;
mp[{vl1 , vl}] = 1;
d[nx][ny]++;
d[i][j]++;
}
nx = i - l , ny = j + u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
mp[{vl , vl1}] = 1;
mp[{vl1 , vl}] = 1;
d[nx][ny]++;
d[i][j]++;
}
nx = i - l , ny = j - u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
mp[{vl , vl1}] = 1;
mp[{vl1 , vl}] = 1;
d[nx][ny]++;
d[i][j]++;
}
nx = i + l , ny = j - u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
mp[{vl , vl1}] = 1;
mp[{vl1 , vl}] = 1;
d[nx][ny]++;
d[i][j]++;
}
}
}
}
int mx = 0 ;
for(int i = 0 ; i < H ; ++i)
for(int j = 0 ; j < W ; ++j){
v[d[i][j]].push_back({i , j});
mx = max(mx , d[i][j]);
}
for(int k = mx ; k ; --k){
while(v[k].size()){
int i = v[k].back().first , j = v[k].back().second;
// cout << i << ' ' << j << endl;
v[k].erase(v[k].begin() + v[k].size() - 1);
if(d[i][j] != k) continue ;
int vl = i * W + j;
Ns.clear();
// cout << i << ' ' << j << endl;
for(int l = 0 ; l <= K ; l++){
int u = K - l ;
int nx = i + l , ny = j + u ;
int vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
use[{vl,vl1}] = 1;
use[{vl1,vl}] = 1;
if(d[i][j] <= 2){
Ns = {vl , vl1};
//cout << Ns[0] << ' ' << Ns[1] << endl;
int a = add_and(Ns);
f.push_back(a);
}else{
d[nx][ny]--;
if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny});
Ns.push_back(vl1);
}
}
nx = i - l , ny = j + u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
use[{vl,vl1}] = 1;
use[{vl1,vl}] = 1;
if(d[i][j] <= 2){
Ns = {vl , vl1};
//cout << Ns[0] << ' ' << Ns[1] << endl;
int a = add_and(Ns);
f.push_back(a);
}else{
d[nx][ny]--;
if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny});
Ns.push_back(vl1);
}
}
nx = i - l , ny = j - u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
use[{vl,vl1}] = 1;
use[{vl1,vl}] = 1;
if(d[i][j] <= 2){
Ns = {vl , vl1};
//cout << Ns[0] << ' ' << Ns[1] << endl;
int a = add_and(Ns);
f.push_back(a);
}else{
d[nx][ny]--;
if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny});
Ns.push_back(vl1);
}
}
nx = i + l , ny = j - u;
vl1 = nx * W + ny;
if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
use[{vl,vl1}] = 1;
use[{vl1,vl}] = 1;
if(d[i][j] <= 2){
Ns = {vl , vl1};
//cout << Ns[0] << ' ' << Ns[1] << endl;
int a = add_and(Ns);
f.push_back(a);
}else{
d[nx][ny]--;
if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny});
Ns.push_back(vl1);
}
}
}
if(d[i][j] > 2){
int a = add_or(Ns);
Ns = {vl , a};
a = add_and(Ns);
f.push_back(a);
}
d[i][j] = 0;
}
}
//cout << f.size() << endl;
add_or(f);
return ;
}
// freopen("C:\\Users\\mhmdsa\\Documents\\c++\\input.txt" , "r" , stdin );
// freopen("C:\\Users\\mhmdsa\\Documents\\c++\\output.txt" , "w" , stdout );
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
0 ms |
384 KB |
Output is correct |
28 |
Correct |
28 ms |
4352 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
768 KB |
Output is correct |
33 |
Correct |
3 ms |
896 KB |
Output is correct |
34 |
Correct |
29 ms |
4352 KB |
Output is correct |
35 |
Correct |
17 ms |
3040 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
0 ms |
384 KB |
Output is correct |
28 |
Correct |
28 ms |
4352 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
768 KB |
Output is correct |
33 |
Correct |
3 ms |
896 KB |
Output is correct |
34 |
Correct |
29 ms |
4352 KB |
Output is correct |
35 |
Correct |
17 ms |
3040 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
38 |
Execution timed out |
1101 ms |
99532 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
2176 KB |
Output is correct |
4 |
Correct |
152 ms |
18808 KB |
Output is correct |
5 |
Correct |
90 ms |
11256 KB |
Output is correct |
6 |
Correct |
24 ms |
4088 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
20 ms |
3956 KB |
Output is correct |
9 |
Correct |
565 ms |
55412 KB |
Output is correct |
10 |
Correct |
264 ms |
32500 KB |
Output is correct |
11 |
Correct |
62 ms |
9336 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Incorrect |
44 ms |
8952 KB |
WA in grader: Too many instructions |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
14192 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
0 ms |
384 KB |
Output is correct |
28 |
Correct |
28 ms |
4352 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
768 KB |
Output is correct |
33 |
Correct |
3 ms |
896 KB |
Output is correct |
34 |
Correct |
29 ms |
4352 KB |
Output is correct |
35 |
Correct |
17 ms |
3040 KB |
Output is correct |
36 |
Correct |
3 ms |
768 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
38 |
Execution timed out |
1101 ms |
99532 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |