叉乘:
#include
#define rep(i,a,b) for(int i=a;i
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll Mode(ll a, ll b, ll mode) {ll sum = 1;if(mode == 1)return 0 ;while (b) {if (b & 1) {sum = (sum * a) % mode;b--;}b /= 2;a = a * a % mode;}return sum;}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;
struct point{
ll x , y ;
}a[10];point q,w ;
double cross(point a,point b)
{
return (a.x*b.y-a.y*b.x);
}
int main(){
T{
cin>>a[1].x>>a[1].y>>a[2].x>>a[2].y>>a[3].x>>a[3].y;
a[4].x=a[1].x-a[3].x;
a[4].y=a[1].y-a[3].y;
a[5].y=a[1].y-a[2].y;
a[5].x=a[1].x-a[2].x;
if(cross(a[4],a[5]) > 0)
printf("Clockwise\n") ;
else
printf("Counterclockwise\n") ;
}
return 0 ;
}
#include
#define rep(i,a,b) for(int i=a;i
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll Mode(ll a, ll b, ll mode) {ll sum = 1;if(mode == 1)return 0 ;while (b) {if (b & 1) {sum = (sum * a) % mode;b--;}b /= 2;a = a * a % mode;}return sum;}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;
ll n , k ;
struct qj{
ll high,low ;
}a[maxn];
int main(){
T{
ll flag = 1 ;
ll n , k ;
scanf("%lld%lld",&n,&k) ;
for(int i = 1 ; i <= n ; i++)
scanf("%lld%lld",&a[i].low ,&a[i].high) ;
ll xx , yy ;
for(int i = 1 ; i < n ; i++){
xx = a[i].low - k ;
yy = a[i].high + k ;
if(yy<a[i+1].low ||xx>a[i+1].high ){
flag=0 ;
break ;
}
else{
a[i+1].low=max(xx,a[i+1].low) ;
a[i+1].high=min(yy,a[i+1].high) ;
}
}
if(!flag){
printf("NO\n") ; continue ;
}
for(int i = n ; i > 1 ; i --){
xx=a[i].low-k,yy=a[i].high+k;
a[i-1].low = max(a[i-1].low ,xx) ;
a[i-1].high =min(a[i-1].high ,yy) ;
}
printf("YES\n") ;
for(int i = 1 ; i < n ; i++){
ll ans = a[i].low ;
printf("%lld ",ans) ;
ll l ,r ;
l = a[i].low - k ;
r = a[i].high + k ;
a[i+1].low = max(a[i+1].low ,l) ;
a[i+1].high = min(a[i+1].high ,r) ;
}
printf("%lld\n",a[n].low ) ;
}
return 0 ;
}
#include
#define rep(i,a,b) for(int i=a;i
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll Mode(ll a, ll b, ll mode) {ll sum = 1;if(mode == 1)return 0 ;while (b) {if (b & 1) {sum = (sum * a) % mode;b--;}b /= 2;a = a * a % mode;}return sum;}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;
ll n , k ;
struct qj{
ll high,low ;
}a[maxn];
int main(){
T{
ll flag = 1 ;
ll n , k ;
scanf("%lld%lld",&n,&k) ;
for(int i = 1 ; i <= n ; i++)
scanf("%lld%lld",&a[i].low ,&a[i].high) ;
ll xx , yy ;
for(int i = 1 ; i < n ; i++){
xx = a[i].low - k ;
yy = a[i].high + k ;
if(yy<a[i+1].low ||xx>a[i+1].high ){
flag=0 ;
break ;
}
else{
a[i+1].low=max(xx,a[i+1].low) ;
a[i+1].high=min(yy,a[i+1].high) ;
}
}
if(!flag){
printf("NO\n") ; continue ;
}
for(int i = n ; i > 1 ; i --){
xx=a[i].low-k,yy=a[i].high+k;
a[i-1].low = max(a[i-1].low ,xx) ;
a[i-1].high =min(a[i-1].high ,yy) ;
}
printf("YES\n") ;
for(int i = 1 ; i < n ; i++){
ll ans = a[i].low ;
printf("%lld ",ans) ;
ll l ,r ;
l = a[i].low - k ;
r = a[i].high + k ;
a[i+1].low = max(a[i+1].low ,l) ;
a[i+1].high = min(a[i+1].high ,r) ;
}
printf("%lld\n",a[n].low ) ;
}
return 0 ;
}