Submission #262069

# Submission time Handle Problem Language Result Execution time Memory
262069 2020-08-12T10:25:45 Z kshitij_sodani Vision Program (IOI19_vision) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#include "vision.h"

void construct_network(int n, int m, int k) {
	//k=1
	//52 points
	if(n==1 or m==1){
		vector<int> cur;
		int pos=n*m;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				vector<int> cur2;
				for(int kk=0;kk<n;kk++){
					for(int ll=0;ll<m;ll++){
						if(abs(i-kk)+abs(j-ll)==k){
							cur2.pb(kk*m+ll);
						}
					}
				}
				if(cur2.size()==0){
					continue;
				}
				add_or(cur2);
				add_and({pos,i*m+j});
				cur.pb(pos+1);
				pos+=2;
			}
		}
		add_or(cur);
		return 0;

	}
	
	vector<int> cur;
	vector<int> cur3;
	int pos=n*m;
	for(int i=0;i<n;i++){
		vector<int> cot;
		for(int j=0;j<m;j++){
			cot.pb(i*m+j);
		}
		add_or(cot);
		cur.pb(pos);
		cur3.pb(pos);
		pos++;
	}
	vector<int> cur2;
	for(int j=0;j<m;j++){
		vector<int> cot;
		for(int i=0;i<n;i++){
			cot.pb(i*m+j);
		}
		add_or(cot);
		cur2.pb(pos);
		cur3.pb(pos);
		pos++;
	}
	int a1=pos;
	pos++;
	add_xor(cur3);
	int a2=-1;
	int a3=-1;
/*	for(auto j:cur){
		cout<<j<<";";
	}
	cout<<endl;*/
	if(n>1){
		vector<int> cur4;
		vector<int> cur5;
		for(auto j:cur){
			cur4.pb(j);
			add_xor(cur4);
			cur5.pb(pos);
			pos++;
		}


		vector<int> cur6;
		for(int j=0;j<n-1;j++){
			add_and({cur5[j],cur5[j+1]});
			cur6.pb(pos);
			pos++;
		}
		add_or(cur6);
		int a4=pos;
	//	cout<<pos<<"/"<<endl;
		pos++;
		//if count=2 in that row a4 checks if they are consecutive
		//compute if count==2
		vector<int> cur7; 
		for(int i=0;i<n-1;i++){
			vector<int> cur8;
			vector<int> cur9;
			for(int j=0;j<=i;j++){
				cur8.pb(cur[j]);
			}
			for(int j=i+1;j<n;j++){
				cur9.pb(cur[j]);
			}
			add_or(cur8);
			add_or(cur9);
			add_and({pos,pos+1});
			pos+=2;
			cur7.pb(pos);
			pos++;
		}
		add_or(cur7);//uses pos,should be 0
		//cout<<pos<<endl;
		pos++;
		add_not(a4);
	//	cout<<pos<<endl;
		pos+=1;
		add_and({pos-2,pos-1});//uses pos+1,should be 1
		a2=pos;
		pos+=1;
	}
	if(m>1){
		vector<int> cur4;
		vector<int> cur5;
		for(auto j:cur2){
			cur4.pb(j);
			add_xor(cur4);
			cur5.pb(pos);
			pos++;
		}
		vector<int> cur6;
		for(int j=0;j<m-1;j++){
			add_and({cur5[j],cur5[j+1]});
			cur6.pb(pos);
			pos++;
		}
		add_or(cur6);
		int a4=pos;
		pos++;
		//if count=2 in that row a4 checks if they are consecutive
		//compute if count==2
		vector<int> cur7; 
		for(int i=0;i<m-1;i++){
			vector<int> cur8;
			vector<int> cur9;
			for(int j=0;j<=i;j++){
				cur8.pb(cur2[j]);
			}
			for(int j=i+1;j<m;j++){
				cur9.pb(cur2[j]);
			}
			add_or(cur8);
			add_or(cur9);
			add_and({pos,pos+1});
			pos+=2;
			cur7.pb(pos);
			pos++;
		}
		add_or(cur7);//uses pos,should be 0
		pos++;
		add_not(a4);
		pos+=1;
		add_and({pos-1,pos-2});//uses pos+1,should be 1
		a3=pos;
		pos+=1;
	}
//	cout<<a1<<":"<<a2<<":"<<a3<<endl;

	if(a2==-1){
		add_and({a1,a3});
	}
	else if(a3==-1){
		add_and({a2,a3});
	}
	else{
		add_or({a2,a3});
		add_and({a1,pos});
	}
	



	

}



//g++   -o bb grader.cpp vision.cpp

/*
2 3 3
0 0 0 1
0 0 0 2
0 0 1 0
0 0 1 1
0 0 1 2
0 1 0 2
0 1 1 0
0 1 1 1
0 1 1 2
0 2 1 0
0 2 1 1
0 2 1 2
1 0 1 1
1 0 1 2
1 1 1 2
-1

*/

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:36:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   return 0;
          ^