Submission #621006

# Submission time Handle Problem Language Result Execution time Memory
621006 2022-08-03T11:02:14 Z beaconmc Vision Program (IOI19_vision) C++14
Compilation error
0 ms 0 KB
#include "vision.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef int ll;
using namespace std;
using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll h,w,k;

vector<int> hashh(vector<int> a){
	return {a[0]+a[1], a[1]-a[0]};
}

int unhashh(vector<int> a){
	vector<int> temp =  {(a[0]-a[1])/2, (a[0]+a[1])/2};

	return w*temp[0]+temp[1];
}
vector<int> arr = {1,0,1};

int add_and(vector<int> a){
	FOR(i,0,a.size()){
		a[i] = arr[a[i]];
	}
	FOR(i,1,a.size()){
		a[0] &= a[i];
	}
	arr.push_back(a[0]);
	return arr.size()-1;
}
int add_xor(vector<int> a){
	FOR(i,0,a.size()){
		a[i] = arr[a[i]];
	}

	FOR(i,1,a.size()){
		a[0] ^= a[i];
	}
	arr.push_back(a[0]);
	return arr.size()-1;
}
int add_or(vector<int> a){
	FOR(i,0,a.size()){
		a[i] = arr[a[i]];
	}
	FOR(i,1,a.size()){
		a[0] |= a[i];
	}
	arr.push_back(a[0]);
	return arr.size()-1;
}
int add_not(int a){
	if(arr[a]) arr.push_back(0);
	else arr.push_back(1);
	return arr.size()-1;
}
void construct_network(int H, int W, int K) {
	h=H; w=W; k=K;

	set<ll> x;
	set<ll> y;


	vector<vector<ll>> stuff;
	FOR(i,0,h){
		FOR(j,0,w){
			stuff.push_back(hashh({i,j}));
		}
	}

	for (auto&i : stuff){
		x.insert(i[0]);
		y.insert(i[1]);
	}
	vector<int> fx, fy, sx, sy;

	for (auto&i : x){

		vector<int> fir,sec;
		for (auto&j : stuff){
			if (j[0] == i) fir.push_back(unhashh(j));
			else if (j[0] == i-k || j[0] == i+k) sec.push_back(unhashh(j));
		}
		if (!(fir.size() && sec.size())){
			fx.push_back(add_and({0,1,2}));
			continue;
		}

		fx.push_back(add_and({add_xor(fir),add_xor(sec)}));

	}
	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : stuff){

			if (j[1] == i) fir.push_back(unhashh(j));
			else if (j[1] < i-k || j[1] > i+k) sec.push_back(unhashh(j));
		}

		if (!(fir.size() && sec.size())){

			fy.push_back(add_and({0,1,2}));
			continue;
		}

		fy.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}


	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : stuff){
			if (j[1] == i) fir.push_back(unhashh(j));
			else if (j[1] == i-k || j[1] == i+k) sec.push_back(unhashh(j));
		}
		if (!(fir.size() && sec.size())){
			sy.push_back(add_and({0,1,2}));
			continue;
		}
		sy.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}

	for (auto&i : x){
		vector<int> fir,sec;
		for (auto&j : stuff){
			if (j[0] == i) fir.push_back(unhashh(j));
			else if (j[0] < i-k || j[0] > i+k) sec.push_back(unhashh(j));
		}
		if (!(fir.size() && sec.size())){
			sx.push_back(add_and({0,1,2}));
			continue;
		}
		sx.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}


	ll a,b,c,d;
	a = add_or(fx);
	b = add_not(add_or(fy));
	c = add_or(sy);
	d = add_not(add_or(sx));


	ll aa = add_and({a,b});
	ll bb = add_and({c,d});

	add_or({aa,bb});

}

Compilation message

vision.cpp: In function 'int add_and(std::vector<int>)':
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   29 |  FOR(i,0,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:29:2: note: in expansion of macro 'FOR'
   29 |  FOR(i,0,a.size()){
      |  ^~~
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   32 |  FOR(i,1,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:32:2: note: in expansion of macro 'FOR'
   32 |  FOR(i,1,a.size()){
      |  ^~~
vision.cpp: In function 'int add_xor(std::vector<int>)':
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   39 |  FOR(i,0,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:39:2: note: in expansion of macro 'FOR'
   39 |  FOR(i,0,a.size()){
      |  ^~~
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   43 |  FOR(i,1,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:43:2: note: in expansion of macro 'FOR'
   43 |  FOR(i,1,a.size()){
      |  ^~~
vision.cpp: In function 'int add_or(std::vector<int>)':
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   50 |  FOR(i,0,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:50:2: note: in expansion of macro 'FOR'
   50 |  FOR(i,0,a.size()){
      |  ^~~
vision.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   53 |  FOR(i,1,a.size()){
      |      ~~~~~~~~~~~~                  
vision.cpp:53:2: note: in expansion of macro 'FOR'
   53 |  FOR(i,1,a.size()){
      |  ^~~
/usr/bin/ld: /tmp/cc4Y16KY.o: in function `add_and(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x210): multiple definition of `add_and(std::vector<int, std::allocator<int> >)'; /tmp/cc5lQkIY.o:vision.cpp:(.text+0x3d0): first defined here
/usr/bin/ld: /tmp/cc4Y16KY.o: in function `add_or(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x230): multiple definition of `add_or(std::vector<int, std::allocator<int> >)'; /tmp/cc5lQkIY.o:vision.cpp:(.text+0x490): first defined here
/usr/bin/ld: /tmp/cc4Y16KY.o: in function `add_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x250): multiple definition of `add_xor(std::vector<int, std::allocator<int> >)'; /tmp/cc5lQkIY.o:vision.cpp:(.text+0x310): first defined here
/usr/bin/ld: /tmp/cc4Y16KY.o: in function `add_not(int)':
grader.cpp:(.text+0x270): multiple definition of `add_not(int)'; /tmp/cc5lQkIY.o:vision.cpp:(.text+0x550): first defined here
collect2: error: ld returned 1 exit status