String Minimization
a尽可能小的话,如果能和c交换更小就交换。
如果a和c相等,b交换能更小,就交换b。
#include <bits/stdc++.h>
//#define int long long
#define per(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define rep(i,j,k) for(int (i)=(j);(i)>=(k);--(i))
#define debug(a) cout<<#a<<"="<<a<<endl
#define all(x) x.begin(),x.end()
#define fr first
#define se second
#define endl '\n'
using namespace std;
void solve(){
string a,b,c,d;
cin>>a>>a>>b>>c>>d;
per(i,0,a.length()-1){
if(c[i]<a[i]){
swap(c[i],a[i]);
swap(b[i],d[i]);
}else if(c[i]==a[i]){
if(d[i]<b[i])
swap(d[i],b[i]);
}
}
cout<<b<<endl;
}
signed main(){
ios::sync_with_stdio(false),cin.tie(nullptr);
int t=1;
while(t--)solve();
return 0;
}
Swimming Pool
即梯形成立条件:腰和>底差,腰差<底差。(还要特判平行四边形 对边都相等的话为no)
#include <bits/stdc++.h>
//#define int long long
#define per(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define rep(i,j,k) for(int (i)=(j);(i)>=(k);--(i))
#define debug(a) cout<<#a<<"="<<a<<endl
#define all(x) x.begin(),x.end()
#define fr first
#define se second
#define endl '\n'
using namespace std;
void solve(){
int p,q,r,s;
cin>>p>>q>>r>>s;
if((q+s)>abs(p-r) and abs(q-s)<abs(p-r) or (p+r)>abs(q-s) and abs(p-r)<abs(q-s)){
if(q==s and p==r){
cout<<"no"<<endl;
}else cout<<"yes"<<endl;
}else cout<<"no"<<endl;
}
signed main(){
ios::sync_with_stdio(false),cin.tie(nullptr);
int t=1;
cin>>t;
while(t--)solve();
return 0;
}