이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "grader.cpp"
#include "vision.h"
#include <bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
const int N = 1e7+5;
int d, h, w, used[N], cnt=0;
void fun(int xx,int yy){
vector<int> v;
for(int i=0;i<=d;i++){
int x = xx-i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=0;i<d;i++){
int x = xx-i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=1;i<=d;i++){
int x = xx+i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
for(int i=1;i<d;i++){
int x = xx+i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w){
v.pb(x*w+y);
}
}
if(v.size()){
add_or(v);
used[cnt]=xx*w+yy;
cnt++;
}
}
void fun1(int xx,int yy){
vector<int> v;
for(int i=0;i<=d;i++){
int x = xx-i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
v.pb(x*w+y);
}
for(int i=0;i<d;i++){
int x = xx-i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
v.pb(x*w+y);
}
for(int i=1;i<=d;i++){
int x = xx+i, y = yy-(d-i);
if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
v.pb(x*w+y);
}
for(int i=1;i<d;i++){
int x = xx+i, y = yy+(d-i);
if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
v.pb(x*w+y);
}
if(v.size()){
add_or(v);
used[cnt] = xx*w+yy;
cnt++;
}
}
void construct_network(int H, int W, int k) {
d=k, h=H, w=W;
if(min(h,w) == 1){
h=max(h,w);
int l=0;
for(int i=0; i+k<h; i++){
add_and({i,i+k});
l++;
}
vector<int>v;
for(int i=0;i<l;i++){
v.pb(i+h);
}
add_or(v);
return;
}
else if(max(h,w) <= 30){
for(int i=0;i<h;i++)
for(int j=0;j<w;j++) fun(i,j);
int last = h*w;
for(int i=0; i<cnt; i++){
int cur = used[i], cur1 = i+last;
vector<int> v = {cur, cur1};
add_and(v);
}
vector<int>v;
for(int j=0; j<cnt; j++){
int i=last+cnt+j;
v.pb(i);
}
add_or(v);
return;
}
else{
memset(used, 0, sizeof(used));
cnt=0;
for(int i=0;i<h;i++)
fun1(i, 0);
for(int i=1;i<w;i++)
fun1(0, i);
int last = h*w;
for(int i=0; i<cnt; i++){
int cur = used[i], cur1 = i+last;
vector<int> v = {cur, cur1};
add_and(v);
}
vector<int>v;
for(int j=0; j<cnt; j++){
int i = last + cnt + j;
v.pb(i);
}
add_or(v);
return;
}
}
/*
2 3 3
0 5
2 3
*/
컴파일 시 표준 에러 (stderr) 메시지
vision.cpp: In function 'void fun1(int, int)':
vision.cpp:48:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
48 | if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
vision.cpp:54:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
54 | if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
vision.cpp:60:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
60 | if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
vision.cpp:65:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
65 | if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |