https://codeforces.com/gym/101630/attachments
B - Box
根据样例可以得出几个式子,具体看代码,只要满足其中之一就可以
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e3+5; 5 ll a[100]; 6 int main(){ 7 ll w,h; 8 for(int i=1;i<=3;i++)cin>>a[i]; 9 sort(a+1,a+4); 10 cin>>w>>h; 11 ll x=2*a[2]+2*a[1]; 12 ll y=a[3]+2*a[1]; 13 14 if(x<y)swap(x,y); 15 ll p=a[2]+2*a[1]; 16 ll q=2*a[1]+2*a[3]; 17 if(p<q)swap(p,q); 18 if(w<h)swap(w,h); 19 20 ll u=a[2]+a[1]; 21 ll v=3*a[3]+a[2]+a[1]; 22 if(u<v)swap(u,v); 23 24 ll g=a[3]+a[1]; 25 ll k=3*a[2]+a[1]+a[3]; 26 if(g<k)swap(g,k); 27 28 29 ll b=a[2]+a[3]; 30 ll c=3*a[1]+a[2]+a[3]; 31 if(b<c)swap(b,c); 32 int f=0; 33 if(w>=x&&h>=y)f++; 34 if(w>=p&&h>=q)f++; 35 if(w>=u&&h>=v)f++; 36 if(w>=g&&h>=k)f++; 37 if(w>=b&&h>=c)f++; 38 if(f)printf("Yes "); 39 else printf("No "); 40 }
D - Designing the Toy
这题当时不会写赛后看懂了某个博主的代码
主要是在一个面上构造,然后跟据输入顺序对这个面进行调整,构造方式结合下图和代码很容易看懂:
1 #define bug(x) cout<<#x<<" is "<<x<<endl 2 #define IO std::ios::sync_with_stdio(0) 3 #include <bits/stdc++.h> 4 #define iter ::iterator 5 #define pa pair<int,ll> 6 #define pp pair<int,pa> 7 using namespace std; 8 #define ll long long 9 #define mk make_pair 10 #define pb push_back 11 #define se second 12 #define fi first 13 #define ls o<<1 14 #define rs o<<1|1 15 const ll mod=1e9+7; 16 const int N=1e3+10; 17 int a[N],b[N]; 18 int mp[N][N]; 19 struct node{ 20 int x,y,z; 21 node(int x1,int y1,int z1):x(x1),y(y1),z(z1){} 22 }; 23 vector<node>v; 24 void gao(int x,int y,int z){ 25 for(int i=0;i<x;i++){ 26 v.pb(node(0,i,i)); 27 mp[i][i]=1; 28 } 29 for(int i=x;i<y;i++){ 30 v.pb(node(0,x-1,i)); 31 mp[x-1][i]=1; 32 } 33 int g=z-y; 34 for(int i=0;i<x;i++){ 35 for(int j=0;j<y;j++){ 36 if(!mp[i][j]&&g>0){ 37 v.pb(node(0,i,j)); 38 g--; 39 } 40 } 41 } 42 if(g){ 43 cout<<-1<<endl; 44 return; 45 } 46 if(b[1]==a[1]&&b[2]==a[3]&&b[3]==a[2]){ 47 for(int i=0;i<v.size();i++){ 48 swap(v[i].x,v[i].y); 49 } 50 } 51 else if(b[1]==a[3]&&b[2]==a[2]&&b[3]==a[1]){ 52 for(int i=0;i<v.size();i++){ 53 swap(v[i].x,v[i].z); 54 } 55 } 56 else if(b[1]==a[2]&&b[2]==a[1]&&b[3]==a[3]){ 57 for(int i=0;i<v.size();i++){ 58 swap(v[i].y,v[i].z); 59 } 60 } 61 else if(b[1]==a[2]&&b[2]==a[3]&&b[3]==a[1]){ 62 for(int i=0;i<v.size();i++){ 63 swap(v[i].x,v[i].y); 64 swap(v[i].x,v[i].z); 65 } 66 } 67 else if(b[1]==a[3]&&b[2]==a[1]&&b[3]==a[2]){ 68 for(int i=0;i<v.size();i++){ 69 swap(v[i].x,v[i].y); 70 swap(v[i].y,v[i].z); 71 } 72 } 73 printf("%d ",v.size()); 74 for(auto tmp:v){ 75 printf("%d %d %d ",tmp.x,tmp.y,tmp.z); 76 } 77 } 78 int main(){ 79 for(int i=1;i<=3;i++){ 80 cin>>a[i]; 81 b[i]=a[i]; 82 } 83 sort(a+1,a+4); 84 gao(a[1],a[2],a[3]); 85 }