답안 #388524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388524 2021-04-11T21:49:05 Z JimmyZJX Vision Program (IOI19_vision) C++14
0 / 100
13 ms 1944 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cassert>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>

using namespace std;

typedef long long LL;
typedef vector<int> Vi;
typedef vector<bool> Vb;
typedef vector<vector<int>> Vii;

#define forR(i, n) for (int i = 0; i < (n); i++)

int add_not(int N);
void Get_le_k(Vi& rs, Vi& d1r, int K, int& dd1_le_k);
int add_and(Vi Ns);
int add_or(Vi Ns);
int add_xor(Vi Ns);

int Get_le_k(const Vi& dr, int K)
{
	Vi rs;
	for (int i = 0; i < dr.size() - K; i++) {
		Vi range; // [i, i+K]
		for (int j = 0; j <= K; j++) {
			range.push_back(i + j);
		}
		int or_range = add_or(range);
		int xor_range = add_xor(range);
		rs.push_back(add_and(Vi{ or_range, add_not(xor_range) }));
	}
	int dd_ge1_leK = add_or(rs);

	int dd_eq0 = add_not(add_or(dr));
	return add_or(Vi{ dd_eq0, dd_ge1_leK });
}

void construct_network(int H, int W, int K) {

	// d1[i] x+y == i    d2[i] x+(W-1-y) == i
	Vii d1(H + W - 1), d2(H + W - 1);

	forR(x, H) forR(y, W) {
		int index = x * W + y;

		int i1 = x + y, i2 = x + (W - 1 - y);
		d1[i1].push_back(index); d2[i2].push_back(index);
	}

	Vi d1r, d2r;

	for (auto& d1_line : d1) {
		d1r.push_back(add_xor(d1_line));
	}
	for (auto& d2_line : d2) {
		d2r.push_back(add_xor(d2_line));
	}

	int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k;
	// d1
	{
		Vi rs;
		for (int i = 0; i < d1r.size() - K; i++) {
			rs.push_back(add_and(Vi{ d1r[i], d1r[i + K] }));
		}
		dd1_eq_k = add_or(rs);

		dd1_le_k = Get_le_k(d1r, K);
	}

	// d2
	{
		Vi rs;
		for (int i = 0; i < d2r.size() - K; i++) {
			rs.push_back(add_and(Vi{ d2r[i], d2r[i + K] }));
		}
		dd2_eq_k = add_or(rs);

		dd2_le_k = Get_le_k(d2r, K);
	}

	int dd1_k = add_and(Vi{ dd1_le_k, dd2_le_k });

	//int dd1_k = add_and(Vi{ dd1_eq_k, dd2_le_k });
	//int dd2_k = add_and(Vi{ dd2_eq_k, dd1_le_k });

	//add_or(Vi{ dd1_k, dd2_k });

	return;
}


#ifdef TEST_LOCAL
int add_not(int N) { return -1; }
int add_and(Vi Ns) { return -1; }
int add_or(Vi Ns) { return -1; }
int add_xor(Vi Ns) { return -1; }

int main() {
	construct_network(200, 200, 1);

	return 0;
}
#endif

Compilation message

vision.cpp: In function 'int Get_le_k(const Vi&, int)':
vision.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < dr.size() - K; i++) {
      |                  ~~^~~~~~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:73:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   for (int i = 0; i < d1r.size() - K; i++) {
      |                   ~~^~~~~~~~~~~~~~~~
vision.cpp:84:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   for (int i = 0; i < d2r.size() - K; i++) {
      |                   ~~^~~~~~~~~~~~~~~~
vision.cpp:69:6: warning: variable 'dd1_eq_k' set but not used [-Wunused-but-set-variable]
   69 |  int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k;
      |      ^~~~~~~~
vision.cpp:69:26: warning: variable 'dd2_eq_k' set but not used [-Wunused-but-set-variable]
   69 |  int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k;
      |                          ^~~~~~~~
vision.cpp:92:6: warning: unused variable 'dd1_k' [-Wunused-variable]
   92 |  int dd1_k = add_and(Vi{ dd1_le_k, dd2_le_k });
      |      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Incorrect 5 ms 716 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (1, 0), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1944 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB on inputs (0, 0), (0, 1), expected 0, but computed 1
3 Halted 0 ms 0 KB -