#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int h,w,k;
vector <int> t;
int current;
int calls=0;
void add_or(vector <int> v){
cout<<"Call No. "<<calls<<": requested ";
for (auto&i:v) cout<<i<<' ';
cout<<endl;
calls++;
int n=v.size();
if (n>10001){
cout<<"Too many instructions on call and_or\n";
exit(0);
}
for (int i=0; i<n; i++){
if (v[i]<0||v[i]>=current){
cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
exit(0);
}
}
int res=0;
for (int i=0; i<n; i++){
if (t[v[i]]==1){
res=1;
break;
}
}
t.push_back(res);
current++;
}
*/
void construct_network(int H,int W,int K){
if (K==1){
for (int i=0; i<H; i++){
vector <int> v;
for (int j=0; j<W; j++) v.push_back(i*W+j);
add_or(v);
}
for (int j=0; j<W; j++){
vector <int> v;
for (int i=0; i<H; i++) v.push_back(i*W+j);
add_or(v);
}
for (int i=0; i<H-1; i++){
vector <int> v;
v.push_back(H*W+i);
v.push_back(H*W+i+1);
add_and(v);
}
for (int i=0; i<W-1; i++){
vector <int> v;
v.push_back(H*W+H+i);
v.push_back(H*W+H+i+1);
add_and(v);
}
vector <int> vv;
for (int i=0; i<H+W-2; i++) vv.push_back(H*W+H+W+i);
add_or(vv);
vector <int> ww;
for (int i=0; i<H+W; i++) ww.push_back(H*W+i);
add_xor(ww);
vector <int> xx;
xx.push_back(H*W+H+W+H+W);
xx.push_back(H*W+H+W+H+W+1);
// add_and(xx);
return;
}
int cnt=0;
map <pair <int,int>,bool> p;
for (int i=0; i<H; i++){
for (int j=0; j<W; j++){
for (int xp=i,yp=j-K; xp!=i-K&&yp!=j; xp--,yp++){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i-K,yp=j; xp!=i&&yp!=j+K; xp++,yp++){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i,yp=j+K; xp!=i+K&&yp!=j; xp++,yp--){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
for (int xp=i+K,yp=j; xp!=i&&yp!=j-K; xp--,yp--){
if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
add_and({i*W+j,xp*W+yp});
cnt++;
p[{i*W+j,xp*W+yp}]=1;
}
}
}
}
if (cnt==1) return;
//cnt results stored in [h*w,h*w+cnt)
vector <int> v;
int curpr=0,cnt1=0;
for (int i=0; i<cnt; i++){
v.push_back(H*W+i);
curpr++;
if (i==cnt-1){
add_or(v);
v.clear();
cnt1++;
curpr=0;
}
}
if (cnt1==1) return;
//cnt1 results stored in [h*w+cnt,h*w+cnt+cnt1)
v.clear();
for (int i=H*W+cnt; i<H*W+cnt+cnt1; i++){
v.push_back(i);
}
add_or(v);
return;
}
/*
int main(){
cin>>h>>w>>k;
for (int i=0; i<h*w; i++){
int v;
cin>>v;
t.push_back(v);
}
current=h*w;
construct_network(h,w,k);
for (auto&i:t) cout<<i<<' ';
cout<<endl;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1132 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
on inputs (48, 2), (50, 2), expected 0, but computed 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |