답안 #332691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332691 2020-12-03T03:19:28 Z nicholask Vision Program (IOI19_vision) C++14
컴파일 오류
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();
	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 ";
	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 ";
	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 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;
				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);
				vector <int> u;
				u.push_back(i*W+j);
				add_not(u);
				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:133:13: error: cannot convert 'std::vector<int>' to 'int'
  133 |     add_not(u);
      |             ^
      |             |
      |             std::vector<int>
In file included from vision.cpp:1:
vision.h:16:17: note:   initializing argument 1 of 'int add_not(int)'
   16 | int add_not(int N);
      |             ~~~~^