#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
#define SIZE(x) (int)x.size()
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define pb push_back
typedef vector<int> vi;
pair<vi,vi> process(vector<vi> diag) {
int SZ=SIZE(diag);
vi one(SZ), two(SZ);
forn(i,SZ) {
assert(!diag.empty());
one[i] = add_or(diag[i]);
two[i] = add_and({one[i], add_not(add_xor(diag[i]))});
}
return {one,two};
}
int join(vi one, vi two, int K) {
if(K==0) return add_xor({0});
vi instructions=two;
int SZ=SIZE(one);
forn(i,SZ) {
vi group;
forsn(j,i,min(SZ,i+K+1)) group.pb(one[i]);
instructions.pb(add_and({add_or(group), add_not(add_xor(group))}));
}
return add_or(instructions);
}
void construct_network(int H, int W, int K) {
int SZ=H+W-1;
vector<vi> diagA(SZ), diagB(SZ);
forn(i,H) forn(j,W) {
diagA[i+j].pb(i*W+j);
diagB[i-j+W-1].pb(i*W+j);
}
auto [oneA, twoA] = process(diagA);
auto [oneB, twoB] = process(diagB);
int aux1 = add_and({join(oneA, twoA, K), join(oneB, twoB, K)});
int aux2 = add_and({join(oneA, twoA, K-1), join(oneB, twoB, K-1)});
add_and({aux1, add_not(aux2)});
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:41:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
41 | auto [oneA, twoA] = process(diagA);
| ^
vision.cpp:42:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
42 | auto [oneB, twoB] = process(diagB);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
3032 KB |
on inputs (126, 120), (176, 169), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |