This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "vision.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int h, w, k;
int cell(int i, int j){
return i*w+j;
}
void p33(){
vector <int> v;
for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) for(int a = 0; a <= k; a++){
int x = i+a, y = j+k-a;
if(x < h && y < w) v.pb(add_and({cell(i, j), cell(x, y)}));
x = i-a, y = j+k-a;
if(x >= 0 && y < w) v.pb(add_and({cell(i, j), cell(x, y)}));
}
add_or(v);
}
void construct_network(int H, int W, int K){
h = H, w = W, k = K;
if((h <= 10 && w <= 10) || min(h, w) == 1){
p33();
return;
}
vector<int> hh, ww;
for(int i = 0; i < h; i++){
vector<int> temp;
for(int j = 0; j < w; j++) temp.pb({cell(i, j)});
hh.pb(add_or(temp));
}
for(int j = 0; j < w; j++){
vector<int> temp;
for(int i = 0; i < h; i++) temp.pb({cell(i, j)});
ww.pb(add_or(temp));
}
vector<int> hw = hh; hw.insert(hw.end(), ww.begin(), ww.end());
int in1 = add_xor(hw);
vector<int> v;
for(int i = 1; i < hh.size(); i++) v.pb(add_and({hh[i], hh[i-1]}));
for(int i = 1; i < ww.size(); i++) v.pb(add_and({ww[i], ww[i-1]}));
int in2 = add_or(v);
add_and({in1, in2});
}
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i = 1; i < hh.size(); i++) v.pb(add_and({hh[i], hh[i-1]}));
| ~~^~~~~~~~~~~
vision.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 1; i < ww.size(); i++) v.pb(add_and({ww[i], ww[i-1]}));
| ~~^~~~~~~~~~~
# | 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... |