#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int wb(int w)
{
if(w<0)
{
w=-1*w;
}
return w;
}
int main()
{
int t, n, w, x2, y1, y2;
cin >> t;
for(int b=0; b<t; b++)
{
cin >> n >> w;
vector <pair <int, pair <int, int> > > Wprawo(n);
vector <int> Pom(n);
for(int i=0; i<n; i++)
{
cin >> Pom[i] >> y1 >> x2 >> y2;
Wprawo[i].first=Pom[i];
}
for(int i=0; i<n; i++)
{
pair <int, int> para1, para2;
cin >> para2.first >> y1 >> x2 >> y2;
Wprawo[i].second.first=para2.first;
para1.first=Pom[i];
para1.second=wb(y2-y1);
Wprawo[i].second.second=para1.second;
para2.second=para1.second;
}
bool war = true;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
if(Wprawo[i].first<Wprawo[j].first && Wprawo[i].second.first>Wprawo[j].second.first && Wprawo[i].second.second+Wprawo[j].second.second>w)
{
war=false;
break;
}
if(Wprawo[i].first>Wprawo[j].first && Wprawo[j].second.first<Wprawo[j].second.first && Wprawo[i].second.second+Wprawo[j].second.second>w)
{
war=false;
break;
}
}
}
if(war==false)
cout <<"NIE"<<endl;
else
cout <<"TAK"<<endl;
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; int wb(int w) { if(w<0) { w=-1*w; } return w; } int main() { int t, n, w, x2, y1, y2; cin >> t; for(int b=0; b<t; b++) { cin >> n >> w; vector <pair <int, pair <int, int> > > Wprawo(n); vector <int> Pom(n); for(int i=0; i<n; i++) { cin >> Pom[i] >> y1 >> x2 >> y2; Wprawo[i].first=Pom[i]; } for(int i=0; i<n; i++) { pair <int, int> para1, para2; cin >> para2.first >> y1 >> x2 >> y2; Wprawo[i].second.first=para2.first; para1.first=Pom[i]; para1.second=wb(y2-y1); Wprawo[i].second.second=para1.second; para2.second=para1.second; } bool war = true; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(Wprawo[i].first<Wprawo[j].first && Wprawo[i].second.first>Wprawo[j].second.first && Wprawo[i].second.second+Wprawo[j].second.second>w) { war=false; break; } if(Wprawo[i].first>Wprawo[j].first && Wprawo[j].second.first<Wprawo[j].second.first && Wprawo[i].second.second+Wprawo[j].second.second>w) { war=false; break; } } } if(war==false) cout <<"NIE"<<endl; else cout <<"TAK"<<endl; } return 0; } |
English