Submission #416730

# Submission time Handle Problem Language Result Execution time Memory
416730 2021-06-02T20:56:50 Z priority_queue Vision Program (IOI19_vision) C++14
0 / 100
2 ms 716 KB
#include <bits/stdc++.h>

#define forint(i, N) for (int i = 0; i < (N); i++)

using namespace std;

vector<int> v = {1, 0, 0, 0, 0, 1};


int add_not(int N);
int add_and(vector<int> N);
int add_or(vector<int> N);
int add_xor(vector<int> N);
 
void construct_network(int h, int w, int k) {
	
	vector<int> right;

	int vsize = h * w - 1;

	for (int i = h - 1; i >= 1; i--) {
		int a = i;
		int b = 0;

		vector<int> tmp;

		while (b < w && a < h) {
			tmp.push_back(a * w + b);

			a++;
			b++;
		}


		//cerr << "ja" << endl;

		

		vsize++;
		right.push_back(vsize);
		add_or(tmp);
	}


	for (int i = 0; i < w; i++) {
		int a = 0;
		int b = i;

		vector<int> tmp;

		while (b < w && a < h) {
			tmp.push_back(a * w + b);

			a++;
			b++;
		}

		

		vsize++;
		right.push_back(vsize);
		add_or(tmp);
	}

	//cerr << vsize << " right diagonal" << endl;

	//cerr << "ja" << endl;

	vector<int> left;

	for (int i = 0; i < h - 1; i++) {
		int a = i;
		int b = 0;

		vector<int> tmp;

		while (b < w && a >= 0) {
			tmp.push_back(a * w + b);

			a--;
			b++;
		}

		vsize++;
		left.push_back(vsize);
		add_or(tmp);
	}


	for (int i = 0; i < w; i++) {
		int a = h - 1;
		int b = i;

		vector<int> tmp;

		while (b < w && a >= 0) {
			tmp.push_back(a * w + b);

			a--;
			b++;
		}

		vsize++;
		left.push_back(vsize);
		add_or(tmp);
	}

	//cerr << vsize << " left diagonal" << endl;
	//cerr << "ja" << endl;
	vector<int> right_test;
	vector<int> left_test;

	forint(i, right.size() - k) {
		vsize++;
		right_test.push_back(vsize);
		add_and({right[i], right[i + k]});
		vsize++;
		left_test.push_back(vsize);
		add_and({left[i], left[i + k]});
	}


	right_test.insert(right_test.end(), left_test.begin(), left_test.end());
	int t1 = ++vsize;
	add_or(right_test);

	//cerr << vsize << "==" << (v.size()-1) << endl;

	//cerr << ">=k " << v[t1] << ":" << t1 << "?" << (v.size()-1) << endl;

	right_test.clear();
	left_test.clear();

	forint(i, right.size() - (k+1)) {
		vsize++;
		right_test.push_back(vsize);
		add_and({right[i], right[i + k+1]});
		vsize++;
		left_test.push_back(vsize);
		add_and({left[i], left[i + k+1]});
	}

	right_test.insert(right_test.end(), left_test.begin(), left_test.end());
	
	int t2 = ++vsize;

	//cerr << right_test.size() << "<---" << endl;
	if (right_test.empty()) {
		add_xor({0, 0});
		//cerr << "here" << endl;
		//cerr << ">=k+1 " << v[t2] << " -- " << v[v.size()-1] << endl;

	} 
	else {
		add_or(right_test);
	}


	t2 = ++vsize;
	add_not(t2);

	//cerr << ">=k+1 " << v[t2] << endl;
	
	add_and({t1, t2});

/*


	//cerr << v[vsize] << endl;

	vsize++;
	add_and({vsize - 4, vsize - 1});
	add_and({vsize - 3, vsize - 2});
	vsize++;




	//cerr << "ja" << endl;
	vector<int> right2;
	vector<int> left2; 

	forint(i, right.size() - k) {
		vector<int> tmp1;
		vector<int> tmp2;

		for (int j = i; j <= i + k; j++) {
			tmp1.push_back(right[j]);
			tmp2.push_back(left[j]);
		}
		//cerr << "ja " <<endl;
		vsize += 2;
		add_or(tmp1);

		add_xor(tmp1);

		add_xor({vsize - 1, vsize});

		vsize++;

		right2.push_back(vsize);

		vsize += 2;

		add_or(tmp2);

		add_xor(tmp2);

		add_xor({vsize - 1, vsize});

		vsize++;

		
		left2.push_back(vsize);
	}
	//cerr << "ja" << endl;
	vsize++;
	add_or(right2);

	//cerr << v[vsize] << endl;

	vsize++;
	add_or(left2);

	vsize++;
	add_or(right_test);

	vsize++;
	add_or(left_test);

	//cerr << v[vsize] << endl;

	vsize++;
	add_and({vsize - 4, vsize - 1});
	add_and({vsize - 3, vsize - 2});
	vsize++;

	add_or({vsize - 1, vsize});
*/
	
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
vision.cpp:113:2: note: in expansion of macro 'forint'
  113 |  forint(i, right.size() - k) {
      |  ^~~~~~
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
vision.cpp:134:2: note: in expansion of macro 'forint'
  134 |  forint(i, right.size() - (k+1)) {
      |  ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 716 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -