Pagini recente » Cod sursa (job #166897) | Cod sursa (job #473260) | Cod sursa (job #2197140) | Cod sursa (job #1869784) | Cod sursa (job #1709131)
#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;
}