Advertisement
Guest User

Untitled

a guest
May 26th, 2018
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int L1,R1,P1,D1;
  6. int L2,R2,P2,D2;
  7. int K , mov[2]={-1,+1};
  8.  
  9.  
  10. void solve(){
  11.  
  12. cin>>L1>>R1>>P1>>D1;
  13. cin>>L2>>R2>>P2>>D2;
  14. cin>>K;
  15.  
  16. int ans=0;
  17. while( K-- ){
  18.  
  19.     if( P1 == R1 && D1==1 )D1=0;
  20.     if( P1 == L1 && D1==0 )D1=1;
  21.     P1 += mov[D1];
  22.  
  23.     if( P2 == R2 && D2==1 )D2=0;
  24.     if( P2 == L2 && D2==0 )D2=1;
  25.     P2 += mov[D2];
  26.  
  27.     ans += ( P1 == P2 );
  28. }
  29.  
  30. cout<<ans<<endl;
  31. }
  32.  
  33. int main(){
  34.  
  35. int T;
  36. cin>>T;
  37. while( T-- )solve();
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement