Submission #615969

# Submission time Handle Problem Language Result Execution time Memory
615969 2022-07-31T16:35:31 Z amunduzbaev Vision Program (IOI19_vision) C++17
0 / 100
2 ms 1492 KB
#include "bits/stdc++.h"
using namespace std;
#include "vision.h"

#ifndef EVAL
#include "grader.cpp"
#endif

#define ar array

void construct_network(int n, int m, int k) {
	vector<vector<int>> a(n + m, vector<int>(n + m, -1));
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			a[i + j][i - j + m] = i * m + j;
		}
	}
	
	n += m;
	int r1 = -1, r2 = -1;
	{
		vector<int> idr(n, -1), idc(n, -1), xc(n, -1), T;
		
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=0;j<n;j++){
				if(~a[i][j]) t.push_back(a[i][j]);
			}
			
			if(!t.empty()) idr[i] = add_or(t);
			t.clear();
			for(int j=0;j<n;j++){
				if(~a[j][i]) t.push_back(a[j][i]);
			}
			
			if(!t.empty()) idc[i] = add_or(t), xc[i] = add_xor(t);
		}
		
		vector<int> tmp(n, -1);
		for(int i=0;i<n;i++){
			if(i >= k && ~idr[i] && ~idr[i - k]){
				tmp[i] = add_and({idr[i], idr[i-k]});
				T.push_back(tmp[i]);
			}
		}
		
		int v = add_or(T);
		T.clear();
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=max(0, i-k);j<i;j++){
				t.push_back(idc[j]);
			}
			
			if(!t.empty()){
				int j = add_or(t);
				int X = add_and({j, idc[i]});
				int Y = add_and({idc[i], add_not(xc[i])});
				T.push_back(add_or({X, Y}));
			}
		}
		
		int v2 = add_or(T);
		r1 = add_and({v, v2});
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			swap(a[i][j], a[j][i]);
		}
	}
	
	{
		vector<int> idr(n, -1), idc(n, -1), xc(n, -1), T;
		
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=0;j<n;j++){
				if(~a[i][j]) t.push_back(a[i][j]);
			}
			
			if(!t.empty()) idr[i] = add_or(t);
			t.clear();
			for(int j=0;j<n;j++){
				if(~a[j][i]) t.push_back(a[j][i]);
			}
			
			if(!t.empty()) idc[i] = add_or(t), xc[i] = add_xor(t);
		}
		
		vector<int> tmp(n, -1);
		for(int i=0;i<n;i++){
			if(i >= k && ~idr[i] && ~idr[i - k]){
				tmp[i] = add_and({idr[i], idr[i-k]});
				T.push_back(tmp[i]);
			}
		}
		
		int v = add_or(T);
		T.clear();
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=max(0, i-k);j<i;j++){
				t.push_back(idc[j]);
			}
			
			if(!t.empty()){
				int j = add_or(t);
				int X = add_and({j, idc[i]});
				int Y = add_and({idc[i], add_not(xc[i])});
				T.push_back(add_or({X, Y}));
			}
		}
		
		int v2 = add_or(T);
		r2 = add_and({v, v2});
	}
	
	add_or({r1, r2});
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1492 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -