답안 #719740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719740 2023-04-06T15:05:04 Z baojiaopisu Vision Program (IOI19_vision) C++14
0 / 100
16 ms 2640 KB
#include "vision.h"
#include <vector>
using namespace std;
#define pb push_back
const int N = 500 + 10;

int id[N][N], row[N], col[N], drow[N], dcol[N], not_dist_col[N], not_dist_row[N];
int dist_col[N], dist_row[N];

void construct_network(int n, int m, int k) {
	freopen("output.txt", "w", stdout);
	int iter = -1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			id[i][j] = ++iter;
		}
	}

	for(int i = 0; i < n; i++) {
		vector<int> q;
		for(int j = 0; j < m; j++) q.pb(id[i][j]);
		row[i] = ++iter;
		add_or(q);
	}

	int d = max(n, m);
	for(int i = 1; i <= d; i++) {
		int cnt = 0;
		int ii = 2, x = i;
		while(x > 1) {
			if(x % ii == 0) {
				++cnt;
				while(x % ii == 0) x /= ii;
			}
			++ii;
		}
		if(cnt > 1 || i >= n) continue;
		vector<int> t;
		for(int j = 0; j < i; j++) {
			if(j + i >= n) break;
			vector<int> q;
			for(int x = j; x < n; x += i) q.pb(row[x]);
			t.pb(++iter);
			add_xor(q);
		}

		++iter;
		add_or(t);
		drow[i] = ++iter;
		add_not(iter - 1);
	}

	for(int i = n - 1; i >= 0; i--) {
		int x = i;
		vector<int> q;
		int ii = 2;
		if(i) q.pb(drow[1]);
		while(x > 1) {
			int curr = 1;
			if(x % ii == 0) {
				while(x % ii == 0) x /= ii, curr *= ii;
			}
			q.pb(drow[curr]);
			++ii;
		}

		for(int j = i + 1; j < n; j++) q.pb(not_dist_row[j]);
		dist_row[i] = ++iter;
		add_and(q);
		not_dist_row[i] = ++iter;
		add_not(iter - 1);
	}

	for(int i = 0; i < m; i++) {
		vector<int> q;
		for(int j = 0; j < n; j++) q.pb(id[j][i]);
		col[i] = ++iter;
		add_or(q);
	}

	for(int i = 1; i <= d; i++) {
		int cnt = 0;
		int ii = 2, x = i;
		while(x > 1) {
			if(x % ii == 0) {
				++cnt;
				while(x % ii == 0) x /= ii;
			}
			++ii;
		}
		if(cnt > 1 || i >= m) continue;
		vector<int> t;
		for(int j = 0; j < i; j++) {
			if(j + i >= m) break;
			vector<int> q;
			for(int x = j; x < m; x += i) q.pb(col[x]);
			t.pb(++iter);
			add_xor(q);
		}

		++iter;
		add_or(t);
		dcol[i] = ++iter;
		add_not(iter - 1);
	}

	for(int i = m - 1; i >= 0; i--) {
		int x = i;
		vector<int> q;
		int ii = 2;
		if(i) q.pb(dcol[1]);
		while(x > 1) {
			int curr = 1;
			if(x % ii == 0) {
				while(x % ii == 0) x /= ii, curr *= ii;
			}
			q.pb(dcol[curr]);
			++ii;
		}

		for(int j = i + 1; j < m; j++) q.pb(not_dist_col[j]);
		dist_col[i] = ++iter;
		add_and(q);
		not_dist_col[i] = ++iter;
		add_not(iter - 1);
	}

	vector<int> q;
	for(int i = 0; i < k; i++) {
		if(i > n - 1) break;
		if(k - i > m - 1) continue;
		++iter;
		add_and({dist_row[i], dist_col[k - i]});
		q.pb(iter);
	}

	add_or(q);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen("output.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 2640 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -