#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
int H, W, K;
int num[201][201];
void subtask5()
{
int case1, case2;
{
vector <int> col_adj_arr;
for (int i=1;i<W;i++){
vector <int> arr;
for (int y=1;y<=H;y++) for (int x=1;x<=W;x++) if (x != i && x != i+1){
arr.push_back(num[y][x]);
}
int all_zero = add_not(add_or(arr));
col_adj_arr.push_back(all_zero);
}
int col_adj = add_or(col_adj_arr);
vector <int> only_row_arr;
for (int i=1;i<=H;i++){
vector <int> arr;
for (int y=1;y<=H;y++) for (int x=1;x<=W;x++) if (y != i){
arr.push_back(num[y][x]);
}
int all_zero = add_not(add_or(arr));
only_row_arr.push_back(all_zero);
}
int only_row = add_or(only_row_arr);
case1 = add_and({col_adj, only_row});
}
{
vector <int> row_adj_arr;
for (int i=1;i<H;i++){
vector <int> arr;
for (int y=1;y<=H;y++) for (int x=1;x<=W;x++) if (y != i && y != i+1){
arr.push_back(num[y][x]);
}
int all_zero = add_not(add_or(arr));
row_adj_arr.push_back(all_zero);
}
int row_adj = add_or(row_adj_arr);
vector <int> only_col_arr;
for (int i=1;i<=W;i++){
vector <int> arr;
for (int y=1;y<=H;y++) for (int x=1;x<=W;x++) if (x != i){
arr.push_back(num[y][x]);
}
int all_zero = add_not(add_or(arr));
only_col_arr.push_back(all_zero);
}
int only_col = add_or(only_col_arr);
case2 = add_and({row_adj, only_col});
}
add_or({case1, case2});
}
void construct_network(int H, int W, int K)
{
::H = H; ::W = W; ::K = K;
int idx = 0;
for (int i=1;i<=H;i++) for (int j=1;j<=W;j++) num[i][j] = idx++;
if (K == 1){
subtask5();
return;
}
// Subtask 1, 2, 3, 5, 6
vector <int> or_arr;
for (int i=1;i<=H;i++) for (int j=1;j<=W;j++){
// For subtask 6
if (!(H <= 30 && W <= 30 || min(H, W) == 1))
if (i != 1 || j != 1)
continue;
vector <int> diamond;
for (int dy=-K;dy<=K;dy++){
for (int sx=-1;sx<2;sx+=2){
int dx = sx*(K-abs(dy));
int y = i+dy, x = j+dx;
if (y < 1 || y > H || x < 1 || x > W) continue;
diamond.push_back(num[y][x]);
}
}
if (diamond.empty()) continue;
int x = add_or(diamond);
or_arr.push_back(add_and({x, num[i][j]}));
}
add_or(or_arr);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:75:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (!(H <= 30 && W <= 30 || min(H, W) == 1))
~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
4796 KB |
WA in grader: Too many inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |