Submission #1044977

#TimeUsernameProblemLanguageResultExecution timeMemory
1044977Alihan_8Vision Program (IOI19_vision)C++17
100 / 100
16 ms2792 KiB
#include "vision.h"

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ln '\n'

void construct_network(int h, int w, int k) {
	auto f = [&](int k){
		auto calc = [&](auto mp){
			vector <int> a;
			
			for ( auto &[it, v]: mp ){
				a.pb(add_or(v));
			}
			
			int n = a.size();
			
			vector <int> pf(n);
			
			pf[0] = a[0];
			
			for ( int i = 1; i < n; i++ ){
				pf[i] = add_or({pf[i - 1], a[i]});
			}
			
			vector <int> id;
			
			for ( int i = k; i < (int)a.size(); i++ ){
				id.pb(add_and({a[i], pf[i - k]}));
			}
			
			return add_or(id);
		};
		
		int x = -1, y = -1;
		
		{ // i + j diagonal
			map <int,vector<int>> mp;
			
			for ( int i = 0; i < h; i++ ){
				for ( int j = 0; j < w; j++ ){
					mp[i + j].pb(i * w + j);
				}
			}
			
			x = calc(mp);
		}
		{ 
			map <int,vector<int>> mp;
			
			for ( int i = 0; i < h; i++ ){
				for ( int j = 0; j < w; j++ ){
					mp[i - j].pb(i * w + j);
				}
			}
			
			y = calc(mp);
		}
		
		return add_or({x, y});
	};
	
	if ( k == h + w - 2 ){
		f(k);
	} else{
		add_and({f(k), add_not(f(k + 1))});
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...