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"
#define lp(i,a,b) for(int i = a; i < b ; i++)
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mk make_pair
#define sz(x) (int)(x.size())
#define pii pair<int,int>
#define mkt make_tuple
#define debug printf
using namespace std ;
int N, M ;
vector<int> v1 , v2 , aux ;
int code(int i, int j) { return i * M + j ; }
bool valid(int x, int y) { return 0 <= min(x,y) && x < N && y < M ; }
int test(vector<int> &v , int K )
{
vector<int> glob ;
for(int i = 0 ; i + K < sz(v) ; i++ )
{
aux.clear() ;
aux.pb( v[i+K] ) ;
aux.pb( v[i] ) ;
glob.pb( add_and(aux) ) ;
//debug("fiz %d %d\n" , v[i],v[i+K]) ;
}
return add_or(glob) ;
}
void construct_network(int H, int W, int K)
{
N = H ;
M = W ;
for(int i = 0 ; i < H-1 ; i++ )
{
int x = i , y = 0 ;
aux.clear() ;
while( valid(x,y) )
{
aux.pb( code(x,y) ) ;
x-- ;
y++ ;
}
v1.pb( add_xor(aux) ) ;
x = i , y = W-1 ;
aux.clear() ;
while( valid(x,y) )
{
aux.pb( code(x,y) ) ;
x-- ;
y-- ;
}
v2.pb(add_xor( aux ) ) ;
}
for(int j = 0 , jj = W-1 ; j < W ; j++, jj-- )
{
int x = H-1 , y = jj ;
aux.clear() ;
while(valid(x,y))
{
aux.pb( code(x,y) ) ;
x-- ;
y-- ;
}
v2.pb( add_xor(aux) ) ;
aux.clear() ;
x = H-1 , y = j ;
while(valid(x,y))
{
aux.pb(code(x,y) ) ;
x-- ;
y++ ;
}
v1.pb( add_xor(aux) ) ;
}
vector<int> auxaux ;
auxaux.pb( test(v1 , K ) ) ;
auxaux.pb( test(v2, K ) ) ;
int z1 = add_or(auxaux) ;
if(K == H + W - 2) return ;
auxaux.clear() ;
auxaux.pb( test(v2, K+1 ) ) ;
auxaux.pb( test(v2, K+1 ) ) ;
int z2 = add_or( auxaux ) ;
z2 = add_not(z2) ;
aux.clear() ;
aux.pb( z1 ) ;
aux.pb(z2) ;
add_and(aux) ;
}
# | 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... |