#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);
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);
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
216 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
216 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
216 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
216 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
3 ms |
596 KB |
Output is correct |
6 |
Correct |
4 ms |
596 KB |
Output is correct |
7 |
Correct |
3 ms |
596 KB |
Output is correct |
8 |
Correct |
5 ms |
880 KB |
Output is correct |
9 |
Correct |
6 ms |
852 KB |
Output is correct |
10 |
Correct |
7 ms |
852 KB |
Output is correct |
11 |
Correct |
6 ms |
852 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
2792 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
808 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
216 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |