Submission #602901

# Submission time Handle Problem Language Result Execution time Memory
602901 2022-07-23T12:31:22 Z alireza_kaviani Vision Program (IOI19_vision) C++17
0 / 100
44 ms 2780 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

#define all(x)	(x).begin(), (x).end()
#define SZ(x)	int((x).size())
#define sep		' '

const int MOD = 1e9 + 7;
const int LOG = 9;

int n , m , k;

int count_bits(int x){
	int res = 0;
	while(x){
		res++;
		x /= 2;
	}
	return res;
}

vector<int> solve(int l , int r){
	vector<int> bits , nots;
	int lg = count_bits(r - l);
	for(int i = 0 ; i < lg ; i++){
		int sz = (1 << i);
		vector<int> ns;
		for(int j = l ; j <= r ; j++){
			vector<int> query;
			for(int k = j ; k <= r ; k++){
				if((k - j) & (1 << i)){
					query.push_back(k);
				}
			}
			if(SZ(query) == 0)	continue;
			int OR = add_or(query);
			query = {OR , j};
			ns.push_back(add_and(query));
		}
		bits.push_back(add_or(ns));
		nots.push_back(add_not(bits.back()));
	}
	vector<int> res;
	for(int i = 0 ; i < min((1 << lg) , k + 1) ; i++){
		vector<int> ns;
		for(int j = 0 ; j < lg ; j++){
			if(i & (1 << j)){
				ns.push_back(bits[j]);
			}
			else{
				ns.push_back(nots[j]);
			}
		}
		res.push_back(add_and(ns));
	}
	return res;
}

void construct_network(int H, int W, int K) {
	n = H; m = W; k = K;
	int mn = MOD , mx = -MOD;
	for(int i = 0 ; i < n ; i++){
		vector<int> ns;
		for(int j = 0 ; j < m ; j++){
			ns.push_back(i * m + j);
		}
		int ind = add_or(ns);
		mn = min(mn , ind);
		mx = max(mx , ind);
	}
	vector<int> A = solve(mn , mx);
	mn = MOD, mx = -MOD;
	for(int i = 0 ; i < m ; i++){
		vector<int> ns;
		for(int j = 0 ; j < n ; j++){
			ns.push_back(j * m + i);
		}
		int ind = add_or(ns);
		mn = min(mn , ind);
		mx = max(mx , ind);
	}
	vector<int> B = solve(mn , mx);
	//assert(SZ(A) == k + 1);
	//assert(SZ(B) == k + 1);
	for(int i : A)	cout << i << sep;
	for(int i : B)	cout << i << sep;
	cout << endl;
	vector<int> ns;
	for(int i = 0 ; i < SZ(A) ; i++){
		for(int j = 0 ; j < SZ(B) ; j++){
			if(i + j != k)	continue;
			vector<int> query = {A[i] , B[j]};
			ns.push_back(add_and(query));
		}
	}
	add_or(ns);
}

Compilation message

vision.cpp: In function 'std::vector<int> solve(int, int)':
vision.cpp:27:7: warning: unused variable 'sz' [-Wunused-variable]
   27 |   int sz = (1 << i);
      |       ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 2780 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -