답안 #332634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332634 2020-12-03T01:57:05 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();
	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){
	int cnt=0;
	map <pair <int,int>,bool> p;
	for (int i=0; i<H; i++){
		for (int j=0; j<W; j++){
			for (int xp=i,yp=j-K; xp!=i-K&&yp!=j; xp--,yp++){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i-K,yp=j; xp!=i&&yp!=j+K; xp++,yp++){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i,yp=j+K; xp!=i+K&&yp!=j; xp++,yp--){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i+K,yp=j; xp!=i&&yp!=j-K; xp--,yp--){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
		}
	}
	if (cnt==1) return;
	//cnt results stored in [h*w,h*w+cnt)
	vector <int> v;
	int curpr=0,cnt1=0;
	for (int i=0; i<cnt; i++){
		v.push_back(H*W+i);
		curpr++;
		if (i==cnt-1||curpr==10000){
			add_or(v);
			v.clear();
			cnt1++;
			curpr=0;
		}
	}
	if (cnt1==1) return;
	//cnt1 results stored in [h*w+cnt,h*w+cnt+cnt1)
	v.clear();
	for (int i=H*W+cnt; i<H*W+cnt+cnt1; i++){
		v.push_back(i);
	}
	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:43:6: error: 'add_and' was not declared in this scope
   43 |      add_and({i*W+j,xp*W+yp});
      |      ^~~~~~~
vision.cpp:50:6: error: 'add_and' was not declared in this scope
   50 |      add_and({i*W+j,xp*W+yp});
      |      ^~~~~~~
vision.cpp:57:6: error: 'add_and' was not declared in this scope
   57 |      add_and({i*W+j,xp*W+yp});
      |      ^~~~~~~
vision.cpp:64:6: error: 'add_and' was not declared in this scope
   64 |      add_and({i*W+j,xp*W+yp});
      |      ^~~~~~~
vision.cpp:79:4: error: 'add_or' was not declared in this scope
   79 |    add_or(v);
      |    ^~~~~~
vision.cpp:91:2: error: 'add_or' was not declared in this scope
   91 |  add_or(v);
      |  ^~~~~~