답안 #248840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
248840 2020-07-13T14:36:08 Z vanic Pick (COI18_pick) C++14
10 / 100
1 ms 640 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(){
	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--;
	}
	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<d/2; i++){
			push();
			xs--;
			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++;
		}
	}
	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<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);
}


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:298:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<sol.size(); i++){
               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -