Cod sursa(job #1709131)

Utilizator ACTeam2016TUIASI NeculaiDimitrie ACTeam2016 Data 28 mai 2016 11:00:28
Problema Carte2 Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 1.48 kb
#include <fstream>
#include <iostream>

using namespace std;

ifstream fin("carte2.in");
ofstream fout("carte2.out");

int main()
{
	int t, carte[2], cutie[3], ok, maxcutie, pozmax;
	int &a = carte[0];
	int &b = carte[1];
	int &c = cutie[0];
	int &d = cutie[1];
	int &e = cutie[2];
	fin >> t;
	for (int i = 1; i <= t; ++i) {
		ok = 1;
		fin >> a >> b >> c >> d >> e;
		if (c < d)
		{
			if (d < e)
				maxcutie = e, pozmax = 2;
			else
				maxcutie = d, pozmax = 1;
		}
		else
		{
			if (c < e)
				maxcutie = e, pozmax = 2;
			else
				maxcutie = c, pozmax = 0;
		}
		if (a < b) {
			//b max
			if (cutie[pozmax] <= b) {
				ok = 0;
			}
			switch (pozmax) {
			case 0://vreific cu 1 si 2
				if (a >= cutie[1] && a >= cutie[2]) ok = 0;
				break;
			case 1:
				if (a >= cutie[0] && a >= cutie[2]) ok = 0;
				break;
			case 2:
				if (a >= cutie[0] && a >= cutie[1]) ok = 0;
				break;
			default: break;
			}


		}

		else {
			//a max
			if (cutie[pozmax] <= a) {
				ok = 0;
			}
			switch (pozmax) {
			case 0://vreific cu 1 si 2
				if (b >= cutie[1] && b >= cutie[2]) ok = 0;
				break;
			case 1:
				if (b >= cutie[0] && b >= cutie[2]) ok = 0;
				break;
			case 2:
				if (b >= cutie[0] && b >= cutie[1]) ok = 0;
				break;
			default: break;
			}
		}
		//if ((a < c && b < d) || (a < d && b< e) || (a < e && b < c))

		if (ok){
			fout << "posibil"<<endl;
		}
		else {
			fout << "imposibil"<<endl;
		}
	}

	return 0;

}