Submission #248861

# Submission time Handle Problem Language Result Execution time Memory
248861 2020-07-13T15:11:27 Z vanic Pick (COI18_pick) C++14
100 / 100
1 ms 384 KB
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <assert.h>

using namespace std;

int a, b, c, d;
vector < pair < int, int > > sol;
int xs, ys;

void push(){
	sol.push_back({xs, ys});
}

void slucaj5(){
	for(int i=0; i<c/2; i++){
		push();
		xs++;
		ys++;
	}
	push();
	xs--;
	ys++;
	for(int i=0; i<c/2-1; i++){
		push();
		xs--;
		ys--;
	}
	for(int i=0; i<d/2-1; i++){
		push();
		xs--;
		ys++;
	}
	push();
	xs--;
	ys--;
	for(int i=0; i<d/2; i++){
		push();
		xs++;
		ys--;
	}
	assert(xs==0 && ys==0);
}


void slucaj1(){
	if(a && b){
		for(int i=0; i<a/2; i++){
			push();
			xs++;
		}
		for(int i=0; i<c/2; i++){
			push();
			xs++;
			ys++;
		}
		push();
		ys++;
		for(int i=0; i<c/2; i++){
			push();
			xs--;
			ys--;
		}
		for(int i=0; i<a/2-1; i++){
			push();
			xs--;
		}
		for(int i=0; i<b/2-1; i++){
			push();
			ys++;
		}
		for(int i=0; i<d/2; i++){
			push();
			xs--;
			ys++;
		}
		push();
		xs--;
		for(int i=0; i<d/2; i++){
			push();
			xs++;
			ys--;
		}
		for(int i=0; i<b/2; i++){
			push();
			ys--;
		}
	}
	else if(!a){
		for(int i=0; i<b/2; i++){
			push();
			ys++;
		}
		if(c){
			for(int i=0; i<c/2; i++){
				push();
				xs++;
				ys++;
			}
			for(int i=0; i<d/2; i++){
				push();
				xs++;
				ys--;
			}
			push();
			ys--;
			for(int i=0; i<d/2; i++){
				push();
				xs--;
				ys++;
			}
			for(int i=0; i<c/2-1; i++){
				push();
				xs--;
				ys--;
			}
			for(int i=0; i<b/2-1; i++){
				push();
				ys--;
			}
			push();
			xs--;
			ys--;
		}
		else{
			for(int i=0; i<d/2; i++){
				push();
				xs++;
				ys--;
			}
			push();
			ys--;
			for(int i=0; i<d/2-1; i++){
				push();
				xs--;
				ys++;
			}
			for(int i=0; i<b/2-1; i++){
				push();
				ys--;
			}
			push();
			xs--;
			ys++;
			
		}
	}
	else{
		for(int i=0; i<a/2; i++){
			push();
			xs++;
		}
		if(c){
			for(int i=0; i<c/2; i++){
				push();
				xs++;
				ys++;
			}
			for(int i=0; i<d/2; i++){
				push();
				xs--;
				ys++;
			}
			push();
			xs--;
			for(int i=0; i<d/2; i++){
				push();
				xs++;
				ys--;
			}
			for(int i=0; i<c/2-1; i++){
				push();
				xs--;
				ys--;
			}
			for(int i=0; i<a/2-1; i++){
				push();
				xs--;
			}
			push();
			xs--;
			ys--;
		}
		else{
			for(int i=0; i<d/2; i++){
				push();
				xs--;
				ys++;
			}
			push();
			xs--;
			for(int i=0; i<d/2-1; i++){
				push();
				xs++;
				ys--;
			}
			for(int i=0; i<a/2-1; i++){
				push();
				xs--;
			}
			push();
			xs++;
			ys--;
			
		}

	}
	assert(xs==0 && ys==0);
}

void slucaj2(){
	push();
	if(a){
		xs++;
		ys++;
		for(int i=0; i<a/2-1; i++){
			push();
			xs++;
		}
		push();
		xs++;
		ys--;
		for(int i=0; i<a/2-1; i++){
			push();
			xs--;
		}
		for(int i=0; i<b/2; i++){
			push();
			ys--;
		}
		for(int i=0; i<d/2; i++){
			push();
			xs++;
			ys--;
		}
		push();
		xs--;
		for(int i=0; i<d/2; i++){
			push();
			xs--;
			ys++;
		}
		for(int i=0; i<b/2; i++){
			push();
			ys++;
		}
		for(int i=0; i<c/2; i++){
			push();
			xs--;
			ys--;
		}
		push();
		xs--;
		for(int i=0; i<c/2; i++){
			push();
			xs++;
			ys++;
		}
	}
	else{
		xs--;
		ys++;
		for(int i=0; i<b/2-1; i++){
			push();
			ys++;
		}
		push();
		xs++;
		ys++;
		for(int i=0; i<b/2-1; i++){
			push();
			ys--;
		}
		for(int i=0; i<c/2; i++){
			push();
			xs++;
			ys++;
		}
		push();
		ys--;
		for(int i=0; i<c/2; i++){
			push();
			xs--;
			ys--;
		}
		for(int i=0; i<d/2; i++){
			push();
			xs++;
			ys--;
		}
		push();
		ys--;
		for(int i=0; i<d/2; i++){
			push();
			xs--;
			ys++;
		}
	}
	assert(xs==0 && ys==0);
}

void slucaj3(){
	for(int i=0; i<a/2; i++){
		push();
		xs--;
	}
	for(int i=0; i<d/2; i++){
		push();
		xs--;
		ys++;
	}
	push();
	ys++;
	for(int i=0; i<d/2; i++){
		push();
		xs++;
		ys--;
	}
	for(int i=0; i<a/2; i++){
		push();
		xs++;
	}
	push();
	xs++;
	ys--;
	for(int i=0; i<b/2; i++){
		push();
		ys--;
	}
	for(int i=0; i<c/2; i++){
		push();
		xs--;
		ys--;
	}
	push();
	xs--;
	for(int i=0; i<c/2; i++){
		push();
		xs++;
		ys++;
	}
	for(int i=0; i<b/2; i++){
		push();
		ys++;
	}
	assert(xs==0 && ys==0);
}

void slucaj4(){
	for(int i=0; i<a/2; i++){
		push();
		xs++;
	}
	for(int i=0; i<c/2; i++){
		push();
		xs++;
		ys++;
	}
	push();
	ys++;
	for(int i=0; i<c/2; i++){
		push();
		xs--;
		ys--;
	}
	for(int i=0; i<a/2; i++){
		push();
		xs--;
	}
	push();
	xs--;
	ys--;
	for(int i=0; i<b/2; i++){
		push();
		ys--;
	}
	for(int i=0; i<d/2; i++){
		push();
		xs++;
		ys--;
	}
	push();
	xs++;
	for(int i=0; i<d/2; i++){
		push();
		xs--;
		ys++;
	}
	for(int i=0; i<b/2; i++){
		push();
		ys++;
	}
	assert(xs==0 && ys==0);
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> c >> d;
	if(a==0 && b==0){
		slucaj5();
	}
	else if(a%2==0 && b%2==0 && c%2==0 && d%2==0){
		slucaj1();
	}
	else if(a%2==0 && b%2==0 && c%2 && d%2){
		slucaj2();
	}
	else if(a%2 && b%2 && d%2){
		slucaj3();
	}
	else{
		slucaj4();
	}
	for(int i=0; i<sol.size(); i++){
		cout << sol[i].first << " " << sol[i].second << '\n';
	}
	return 0;
}

Compilation message

pick.cpp: In function 'int main()':
pick.cpp:419:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<sol.size(); i++){
               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 0 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 0 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 0 ms 384 KB Output is correct
41 Correct 0 ms 384 KB Output is correct
42 Correct 0 ms 384 KB Output is correct
43 Correct 0 ms 384 KB Output is correct