Submission #593015

# Submission time Handle Problem Language Result Execution time Memory
593015 2022-07-10T07:38:01 Z Lucpp Vision Program (IOI19_vision) C++17
20 / 100
31 ms 2044 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

int solveDiv(int N, int start, int K){
	vector<int> v;
	for(int i = 0; i < min(K, N-K); i++){
		vector<int> w;
		for(int j = i; j < N; j += K) w.push_back(start+j);
		v.push_back(add_xor(w));
	}
	for(int i = N-K; i < K; i++) v.push_back(i);
	return add_not(add_or(v));
}

bool isPrimePower(int i){
	int div = -1;
	for(int j = 2; j < i; j++){
		if(i % j == 0){
			if(div == -1) div = j;
			else if(j % div != 0) return false;
		}
	}
	return true;
}

int solve1D(int N, vector<int> mult, int K){
	vector<int> good, bad;
	for(int i = 1; i < N; i++){
		if(!isPrimePower(i)) continue;
		if(K % i == 0) good.push_back(mult[i]);
		else bad.push_back(mult[i]);
	}
	int a = -1, b = -1;
	if(!bad.empty()) a = add_not(add_or(bad));
	b = add_and(good);
	if(a == -1) return b;
	return add_and({a, b});
}

void construct_network(int H, int W, int K) {
	int row_start = -1, col_start = -1;
	for(int i = 0; i < H; i++){
		vector<int> v;
		for(int j = 0; j < W; j++) v.push_back(i*W+j);
		int x = add_or(v);
		if(i == 0) row_start = x;
	}
	for(int j = 0; j < W; j++){
		vector<int> v;
		for(int i = 0; i < H; i++) v.emplace_back(i*W+j);
		int x = add_or(v);
		if(j == 0) col_start = x;
	}
	vector<int> row(H), col(W);
	{ // k = 0
		vector<int> v;
		for(int i = 0; i < H; i++) v.push_back(row_start+i);
		row[0] = add_xor(v);
		v.clear();
		for(int i = 0; i < W; i++) v.push_back(col_start+i);
		col[0] = add_xor(v);
	}
	vector<int> multR(H), multC(W);
	for(int k = 1; k < H; k++){
		if(!isPrimePower(k)) continue;
		multR[k] = solveDiv(H, row_start, k);
	}
	for(int k = 1; k < W; k++){
		if(!isPrimePower(k)) continue;
		multC[k] = solveDiv(W, col_start, k);
	}
	for(int k = 1; k < H; k++){
		row[k] = solve1D(H, multR, k);
	}
	for(int k = 1; k < W; k++){
		col[k] = solve1D(W, multC, k);
	}
	vector<int> todo;
	for(int kr = 0; kr < H; kr++){
		int kc = K-kr;
		if(kc >= 0 && kc < W){
			todo.push_back(add_and({row[kr], col[kc]}));
		}
	}
	add_or(todo);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Incorrect 1 ms 296 KB on inputs (0, 1), (2, 1), expected 0, but computed 1
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Incorrect 1 ms 296 KB on inputs (0, 1), (2, 1), expected 0, but computed 1
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Incorrect 1 ms 296 KB on inputs (0, 1), (2, 1), expected 0, but computed 1
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Incorrect 1 ms 296 KB on inputs (0, 1), (2, 1), expected 0, but computed 1
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 724 KB Output is correct
2 Correct 12 ms 772 KB Output is correct
3 Correct 13 ms 760 KB Output is correct
4 Correct 12 ms 708 KB Output is correct
5 Correct 11 ms 724 KB Output is correct
6 Correct 15 ms 688 KB Output is correct
7 Correct 11 ms 724 KB Output is correct
8 Correct 12 ms 744 KB Output is correct
9 Correct 12 ms 760 KB Output is correct
10 Correct 12 ms 676 KB Output is correct
11 Correct 12 ms 780 KB Output is correct
12 Correct 12 ms 692 KB Output is correct
13 Correct 12 ms 724 KB Output is correct
14 Correct 14 ms 824 KB Output is correct
15 Correct 12 ms 724 KB Output is correct
16 Correct 12 ms 724 KB Output is correct
17 Correct 12 ms 684 KB Output is correct
18 Correct 12 ms 720 KB Output is correct
19 Correct 12 ms 724 KB Output is correct
20 Correct 12 ms 704 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 432 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 6 ms 724 KB Output is correct
9 Correct 7 ms 724 KB Output is correct
10 Correct 7 ms 724 KB Output is correct
11 Correct 6 ms 688 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 12 ms 672 KB Output is correct
14 Correct 12 ms 736 KB Output is correct
15 Correct 12 ms 740 KB Output is correct
16 Correct 12 ms 732 KB Output is correct
17 Correct 11 ms 724 KB Output is correct
18 Correct 12 ms 748 KB Output is correct
19 Correct 13 ms 756 KB Output is correct
20 Correct 18 ms 1232 KB Output is correct
21 Correct 18 ms 1308 KB Output is correct
22 Correct 18 ms 1360 KB Output is correct
23 Correct 17 ms 1292 KB Output is correct
24 Correct 18 ms 1232 KB Output is correct
25 Correct 18 ms 1256 KB Output is correct
26 Correct 18 ms 1264 KB Output is correct
27 Correct 30 ms 1952 KB Output is correct
28 Correct 30 ms 1976 KB Output is correct
29 Correct 31 ms 2032 KB Output is correct
30 Correct 30 ms 1992 KB Output is correct
31 Correct 30 ms 2044 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1976 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Incorrect 1 ms 296 KB on inputs (0, 1), (2, 1), expected 0, but computed 1
11 Halted 0 ms 0 KB -