youtube channel : https://youtube.com/c...
youtube channel : https://youtube.com/channel/UCYzdgz0Xhcb0tFp_b3gTesQ
Tom And Jerry 1 Problem Code: TANDJ1
There is a grid of size
steps?
Note: Tom can go back to the same cell multiple times.
Input
- The first line contains an integer
- .
Output
For each testcase, output in a single line "YES" if Tom can reach Jerry's cell in exactly
moves and "NO" if not.
You may print each character of the string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).
Constraints
Subtasks
Subtask #1 (100 points): original constraints
Sample Input
3
1 1 2 2 2
1 1 2 3 4
1 1 1 0 3
Sample Output
YES
NO
YES
Explanation
Test Case
: A possible sequence of moves is.
Test Case
: There is a possible sequence in moves, but not in exactlymoves.
Test Case
: A possible sequence of moves is===============================================
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define t() int test;cin>>test;while(test--)
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define fr(i, n) for(int i=n-1;i>=0;i--)
#define fo(i,n) for(int i=0;i<n;i++)
#define f(i,a,n) for(int i=a;i<=n;i++)
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
bool isPrime(int n){
if(n==1) return false;
if(n==2) return true;
for(int i=2;i*i<=n;i++){
if(n%i==0)return false;
}
return true;
}
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << endl;
//use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
void init(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("outp.txt", "w", stdout);
#endif
}
int32_t main(){
init();
fast
t(){
int a,b,c,d,k;cin>>a>>b>>c>>d>>k;
int diff = abs(b-d) + abs(a-c);
int sum= (d+b)+(a+c);
if(diff%2==0){
if(k%2==0 && k>=diff){
cout<<"YES"<<endl;
}
else {
cout<<"NO"<endl;
}
}
else {
if(k%2!=0 && k>=diff){
cout<<"YES"<<endl;
}
else {
cout<<"NO"<<endl;
}
}
}
return 0;
}
