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 <bits/stdc++.h>
#include "vision.h"
//#include "grader.cpp"
using namespace std;
int h ,w ,k;
int d(int i ,int j){ return i*w+j; }
int dist(int r ,int c ,int i ,int j){
return abs(r-i) + abs(j-c);
}
vector <int> getAt(int r ,int c){
vector <int> ret;
for(int i=r; i<h; i++)
for(int j=0; j<w; j++)
if(!(i==r&&j==c-k) && dist(i ,j ,r ,c) == k)
ret.push_back(d(i ,j));
return ret;
}
void construct_network(int H, int W, int K) { h=H ,w=W ,k=K;
vector<vector <int>> diags(H ,vector<int>(W ,-1));
int id = h*w;
for(int i=0; i<h; i++)
for(int j=0; j<w; j++){
auto nb = getAt(i ,j);
if(nb.size())
add_or(nb) ,diags[i][j] = id++;
}
vector<vector <int>> prs(H ,vector<int>(W ,-1));
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
if(~diags[i][j])
add_and({d(i ,j) ,diags[i][j]}) ,prs[i][j] = id++;
vector<int> tot;
for(auto&v : prs)
for(auto&i : v)
if(~i) tot.push_back(i);
add_or(tot);
}
# | 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... |