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;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vi rows, cols, ind, auxrow, auxcol, fin;
void construct_network ( int H, int W, int K )
{
rows.clear();
for ( int i = 0; i < H; i++ )
{
ind.clear();
for ( int j = 0; j < W; j++ )
ind.push_back ( i * W + j );
rows.push_back ( add_or ( ind ) );
}
cols.clear();
for ( int j = 0; j < W; j++ )
{
ind.clear();
for ( int i = 0; i < H; i++ )
ind.push_back ( i * W + j );
cols.push_back ( add_or ( ind ) );
}
fin.clear();
auxrow.clear();
for ( int x = 0; x + K < H; x++ )
{
ind.clear();
ind.push_back ( rows[x] );
ind.push_back ( rows[x + K] );
auxrow.push_back ( add_and ( ind ) );
}
if ( !auxrow.empty() )
{
ind.clear();
ind.push_back ( add_or ( auxrow ) );
ind.push_back ( add_xor ( cols ) );
fin.push_back ( add_and ( ind ) );
}
auxcol.clear();
for ( int x = 0; x + K < W; x++ )
{
ind.clear();
ind.push_back ( cols[x] );
ind.push_back ( cols[x + K] );
auxcol.push_back ( add_and ( ind ) );
}
if ( !auxcol.empty() )
{
ind.clear();
ind.push_back ( add_xor ( rows ) );
ind.push_back ( add_or ( auxcol ) );
fin.push_back ( add_and ( ind ) );
}
for ( int i = 1; i < K; i++ )
{
if ( i < H && K - i < W )
{
auxrow.clear(), auxcol.clear();
for ( int x = 0; x + i < H; x++ )
{
ind.clear();
ind.push_back ( rows[x] );
ind.push_back ( rows[x + i] );
auxrow.push_back ( add_and ( ind ) );
}
for ( int x = 0; x + K - i < W; x++ )
{
ind.clear();
ind.push_back ( cols[x] );
ind.push_back ( cols[x + K - i] );
auxcol.push_back ( add_and ( ind ) );
}
ind.clear();
ind.push_back ( add_or ( auxrow ) );
ind.push_back ( add_or ( auxcol ) );
fin.push_back ( add_and ( ind ) );
}
}
add_or ( fin );
}
# | 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... |