Submission #332685

# Submission time Handle Problem Language Result Execution time Memory
332685 2020-12-03T03:03:45 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 ";
	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=0;
	for (int i=0; i<n; i++){
		if (t[v[i]]==1){
			res=1;
			break;
		}
	}
	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){
		for (int i=0; i<H: i++){
			for (int j=0; j<W; j++){
				vector <int> v;
				v.push_back(i*W+j);
				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);
				}
				add_xor(v);
				add_or(v);
				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);
			}
		}
		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:72:17: warning: range-based 'for' loops with initializer only available with '-std=c++2a' or '-std=gnu++2a'
   72 |   for (int i=0; i<H: i++){
      |                 ^
vision.cpp:72:20: error: found ':' in nested-name-specifier, expected '::'
   72 |   for (int i=0; i<H: i++){
      |                    ^
      |                    ::
vision.cpp:72:19: error: 'H' is not a class, namespace, or enumeration
   72 |   for (int i=0; i<H: i++){
      |                   ^
vision.cpp:96:17: error: expected initializer before ';' token
   96 |   vector <int> f;
      |                 ^
vision.cpp:96:17: error: could not convert 'f' from 'std::vector<int>' to 'bool'
vision.cpp:97:3: error: expected primary-expression before 'for'
   97 |   for (int i=0; i<H; i++){
      |   ^~~
vision.cpp:96:18: error: expected ')' before 'for'
   96 |   vector <int> f;
      |                  ^
      |                  )
   97 |   for (int i=0; i<H; i++){
      |   ~~~             
vision.cpp:72:7: note: to match this '('
   72 |   for (int i=0; i<H: i++){
      |       ^
vision.cpp:100:10: error: 'f' was not declared in this scope
  100 |   add_or(f);
      |          ^