#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;
vector<int> all;
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]);
}
}
if(SZ(ns) == 0){
res.push_back(add_xor(all));
continue;
}
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);
all.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);
if(SZ(A) - 1 + SZ(B) - 1 < k){
add_xor(all);
return;
}
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:28:7: warning: unused variable 'sz' [-Wunused-variable]
28 | int sz = (1 << i);
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
980 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
596 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
5 |
Correct |
4 ms |
640 KB |
Output is correct |
6 |
Correct |
4 ms |
596 KB |
Output is correct |
7 |
Correct |
3 ms |
596 KB |
Output is correct |
8 |
Correct |
6 ms |
872 KB |
Output is correct |
9 |
Correct |
5 ms |
852 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
6 ms |
860 KB |
Output is correct |
12 |
Correct |
6 ms |
852 KB |
Output is correct |
13 |
Incorrect |
7 ms |
980 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
2852 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
596 KB |
Output is correct |
4 |
Correct |
5 ms |
852 KB |
Output is correct |
5 |
Incorrect |
8 ms |
980 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |