답안 #316594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316594 2020-10-26T19:04:58 Z amunduzbaev Vision Program (IOI19_vision) C++14
44 / 100
6 ms 640 KB
//#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;
			v.pb(cur);
			v.pb(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{
		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;
			v.pb(cur);
			v.pb(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

*/

Compilation message

vision.cpp: In function 'void fun1(int, int)':
vision.cpp:47:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   47 |   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:61:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   61 |   if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0){
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
vision.cpp:67:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   67 |   if(x>=0 && x<h &&y>=0 &&y<w && x==0 || y==0){
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 4 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 4 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Incorrect 0 ms 256 KB WA in grader: Invalid index
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB WA in grader: Invalid index
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB WA in grader: Invalid index
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 4 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Incorrect 0 ms 256 KB WA in grader: Invalid index
39 Halted 0 ms 0 KB -