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>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
int n, m;
int last;
vector<int> D;
int c(int x, int y){
return x * m + y;
}
void construct_network(int H, int W, int K) {
n = H, m = W;
last = n*m;
vector<int> diag, diag2;
for(int sum = 0; sum < n + m - 1; ++sum){
vector<int> L;
for(int i = 0; i < n; ++i){
for(int j = m - 1; j >= 0; --j){
if(j + i == sum){
L.pb(c(i, j));
// cout << i << ' ' << j << '\n';
}
}
}
if(L.empty()) continue;
// cout << '\n';
diag.pb(add_or(L));
}
for(int sum = -n-m; sum < n + m; ++sum){
vector<int> L;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(i - j == sum){
L.pb(c(i, j));
// cout << i << ' ' << j << '\n';
}
}
}
// cout << '\n';
if(L.empty()) continue;
diag2.pb(add_or(L));
}
vector<int> diag_pref(diag.size());
vector<int> diag_pref2(diag2.size());
diag_pref[0] = diag[0];
diag_pref2[0] = diag2[0];
for(int i = 1; i < diag.size(); ++i){
diag_pref[i] = add_or({diag_pref[i - 1], diag[i]});
}
for(int i = 1; i < diag2.size(); ++i){
diag_pref2[i] = add_or({diag_pref2[i - 1], diag2[i]});
}
vector<int> F, G;
for(int i = 0; i < diag.size(); ++i){
// sum = i
int j = i - K - 1;
// cout << i << ' ' << j << '\n';
if(j >= 0){
F.pb(add_and({diag[i], diag_pref[j]}));
}
if(j >= 0){
F.pb(add_and({diag2[i], diag_pref2[j]}));
}
j = i - K;
if(j >= 0){
G.pb(add_and({diag[i], diag_pref[j]}));
}
if(j >= 0){
G.pb(add_and({diag2[i], diag_pref2[j]}));
}
}
// cout << diag.size() << '\n';
// cout << diag2.size() << '\n';
if(F.empty()){
add_or(G);
}else{
int x = add_or(G);
int y = add_or(F);
add_xor({x, y});
}
}
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:51:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for(int i = 1; i < diag.size(); ++i){
| ~~^~~~~~~~~~~~~
vision.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i = 1; i < diag2.size(); ++i){
| ~~^~~~~~~~~~~~~~
vision.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i = 0; i < diag.size(); ++i){
| ~~^~~~~~~~~~~~~
# | 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... |