Submission #332698

# Submission time Handle Problem Language Result Execution time Memory
332698 2020-12-03T03:38:59 Z nicholask Vision Program (IOI19_vision) C++14
Compilation error
0 ms 0 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int h,w,k;
vector <int> t;
int current;
int calls=0;
void add_or(vector <int> v){
	cout<<"Call No. "<<calls<<": requested or ";
	for (auto&i:v) cout<<i<<' ';
	cout<<endl;
	calls++;
	int n=v.size();
	for (int i=0; i<n; i++){
		if (v[i]<0||v[i]>=current){
			cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
			exit(0);
		}
	}
	int res=0;
	for (int i=0; i<n; i++){
		if (t[v[i]]==1){
			res=1;
			break;
		}
	}
	t.push_back(res);
	current++;
}
void add_xor(vector <int> v){
	cout<<"Call No. "<<calls<<": requested xor ";
	for (auto&i:v) cout<<i<<' ';
	cout<<endl;
	calls++;
	int n=v.size();
	for (int i=0; i<n; i++){
		if (v[i]<0||v[i]>=current){
			cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
			exit(0);
		}
	}
	int res=0;
	for (int i=0; i<n; i++){
		if (t[v[i]]==1){
			res^=1;
		}
	}
	t.push_back(res);
	current++;
}
void add_and(vector <int> v){
	cout<<"Call No. "<<calls<<": requested and ";
	for (auto&i:v) cout<<i<<' ';
	cout<<endl;
	calls++;
	int n=v.size();
	if (n>10001){
		cout<<"Too many instructions on call and_or\n";
		exit(0);
	}
	for (int i=0; i<n; i++){
		if (v[i]<0||v[i]>=current){
			cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
			exit(0);
		}
	}
	int res=1;
	for (int i=0; i<n; i++){
		if (t[v[i]]==0){
			res=0;
			break;
		}
	}
	t.push_back(res);
	current++;
}
void add_not(int v){
	cout<<"Call No. "<<calls<<": requested not ";
	cout<<v<<endl;
	calls++;
	if (v<0||v>=current){
		cout<<"Invalid index provided on call and_or: "<<0<<"th element requested for "<<v;
		exit(0);
	}
	int res=1;
	if (t[v]==1){
		res=0;
	}
	t.push_back(res);
	current++;
}*/
void construct_network(int H,int W,int K){
	if (K==1){
		for (int i=0; i<H; i++){
			vector <int> v;
			for (int j=0; j<W; j++) v.push_back(i*W+j);
			add_or(v);
		}
		for (int j=0; j<W; j++){
			vector <int> v;
			for (int i=0; i<H; i++) v.push_back(i*W+j);
			add_or(v);
		}
		for (int i=0; i<H-1; i++){
			vector <int> v;
			v.push_back(H*W+i);
			v.push_back(H*W+i+1);
			add_and(v);
		}
		for (int i=0; i<W-1; i++){
			vector <int> v;
			v.push_back(H*W+H+i);
			v.push_back(H*W+H+i+1);
			add_and(v);
		}
		vector <int> vv;
		for (int i=0; i<H+W-2; i++) vv.push_back(H*W+H+W+i);
		add_or(vv);
		vector <int> ww;
		for (int i=0; i<H+W; i++) ww.push_back(H*W+i);
		add_xor(ww);
		vector <int> xx;
		xx.push_back(H*W+H+W+H+W-2);
		xx.push_back(H*W+H+W+H+W-1);
		add_and(xx);
		return;
	} else if (max(H,W)<=100||min(H,W)==1){
	    vector <int> initv,initw;
	    int initnot;
		for (int i=0; i<H; i++){
			for (int j=0; j<W; j++){
				vector <int> v;
				for (int x=i,y=j-K; x!=i-K&&y!=j; x--,y++){
					if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
				}
				for (int x=i-K,y=j; x!=i&&y!=j+K; x++,y++){
					if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
				}
				for (int x=i,y=j+K; x!=i+K&&y!=j; x++,y--){
					if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
				}
				for (int x=i+K,y=j; x!=i&&y!=j-K; x--,y--){
					if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
				}
				if (v.empty()){
				    add_xor(initv);
				    add_not(intitnot);
				    add_xor(initw);
				    continue;
				}
				add_xor(v);
				add_not(i*W+j);
				vector <int> w;
				w.push_back(H*W+3*(i*W+j));
				w.push_back(H*W+3*(i*W+j)+1);
				add_xor(w);
				if (!i&&!j){
				    initv=v;
				    initw=w;
				    initnot=i*W+j;
				}
			}
		}
		vector <int> f;
		for (int i=0; i<H; i++){
			for (int j=0; j<W; j++) f.push_back(H*W+3*(i*W+j)+2);
		}
		add_or(f);
		return;
	}
	vector <int> v;
	for (int x=K; x>=0; x--){
		int y=K-x;
		if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
	}
	add_or(v);
	return;
}
/*
int main(){
	cin>>h>>w>>k;
	for (int i=0; i<h*w; i++){
		int v;
		cin>>v;
		t.push_back(v);
	}
	current=h*w;
	construct_network(h,w,k);
	for (auto&i:t) cout<<i<<' ';
	cout<<endl;
}
*/

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:148:17: error: 'intitnot' was not declared in this scope; did you mean 'initnot'?
  148 |         add_not(intitnot);
      |                 ^~~~~~~~
      |                 initnot