제출 #582783

#제출 시각아이디문제언어결과실행 시간메모리
582783thezomb1eVision Program (IOI19_vision)C++17
44 / 100
71 ms7420 KiB
//thatsramen

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "vision.h"

#define eb emplace_back
#define pb push_back
#define ft first
#define sd second
#define pi pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(...) dbg_out(__VA_ARGS__)

using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;

//Constants
const ll INF = 5 * 1e18;
const int IINF = 2 * 1e9;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ld PI = 3.14159265359;

//Templates
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';}
void dbg_out() {cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
template<typename T> void mins(T& x, T y) {x = min(x, y);}
template<typename T> void maxs(T& x, T y) {x = max(x, y);}
template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void construct_network(int H, int W, int K) {
	vector<int> vpos;
	int pp = H * W, n_size = 20;
	int one, zero;
	{
		vector<int> Ns;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) Ns.pb(i * W + j);
			add_xor(Ns);
			vpos.pb(pp++);
		}
	}
	{
		vector<int> Ns;
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < H; j++) Ns.pb(j * W + i);
			add_xor(Ns);
			vpos.pb(pp++);
		}
		add_or(Ns);
		one = pp;
		pp++;
		zero = pp;
		for (int i = 0; i < n_size; i++, pp++) {
			add_and(Ns);
		}
	}
	int sz = vpos.size();
	for (int it = 0; it < sz; it++) {
		for (int i = 0; i < n_size; i++, pp++) {
			if (i % 2 == 0) {
				// carry bit
				if (i == 0) {
					add_or({vpos[it]});
				} else {
					add_and({pp - n_size - 1, pp - 2});
				}
			} else {
				// value bit
				add_xor({pp - n_size, pp - 1});
			}
		}
	}
	for (int i = 0, j = pp - n_size + 1; i < 10; i++, j += 2) {
		if (K & (1 << i)) {
			add_xor({zero, j});
		} else {
			add_xor({one, j});
		}
	}
	vector<int> Ns;
	for (int i = 0; i < 10; i++) {
		Ns.pb(pp + i);
	}
	add_and(Ns);
}
#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...