题目来自2018广西省赛
A题:Welcome to Collegiate Programming Contest
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 int t; 9 cin>>t; 10 while(t--) 11 { 12 cin>>n; 13 for(int i=0;i<n;i++) 14 { 15 if(i) 16 { 17 cout<<" "; 18 } 19 cout<<"AC"; 20 } 21 cout<<endl; 22 } 23 return 0; 24 }
B题:Practice
1 #include <iostream> 2 #include<bits/stdc++.h> 3 using namespace std; 4 const int N=6; 5 struct node{ 6 int time; 7 int value; 8 }op[N]; 9 bool cmp1(node a,node b) 10 { 11 if(a.time==b.time) 12 { 13 return a.value>b.value; 14 } 15 return a.time<b.time; 16 } 17 bool cmp2(node a,node b) 18 { 19 if(a.value==b.value) 20 { 21 return a.time<b.time; 22 } 23 return a.value>b.value; 24 } 25 int main() 26 { 27 int t; 28 scanf("%d",&t); 29 int n,m; 30 while(t--) 31 { 32 scanf("%d %d",&n,&m); 33 for(int i=1;i<=n;i++) 34 { 35 scanf("%d",&op[i].time); 36 } 37 for(int i=1;i<=n;i++) 38 { 39 scanf("%d",&op[i].value); 40 } 41 sort(op+1,op+1+n,cmp1); 42 int i=1,ans1=0,ans2=0,mm=m; 43 while(mm>=op[i].time) 44 { 45 ans1+=op[i].value; 46 mm-=op[i].time; 47 i++; 48 } 49 i=1; 50 mm=m; 51 sort(op+1,op+1+n,cmp2); 52 while(mm>=op[i].time) 53 { 54 ans2+=op[i].value; 55 mm-=op[i].time; 56 i++; 57 } 58 if(ans1==ans2) 59 { 60 printf("SAME "); 61 } 62 else if(ans1>ans2) 63 { 64 printf("A "); 65 } 66 else 67 { 68 printf("B "); 69 } 70 } 71 return 0; 72 } 73
C题:Team Match
1 #include <iostream> 2 #include<bits/stdc++.h> 3 using namespace std; 4 const int N=10; 5 struct node 6 { 7 int x,y,z; 8 }; 9 int a[2*N],vis[2*N]; 10 int ans,n,m; 11 bool cmp(int x,int y) 12 { 13 return x>y; 14 } 15 int main() 16 { int t; 17 scanf("%d",&t); 18 while(t--) 19 { 20 scanf("%d %d",&n,&m); 21 for(int i=1; i<=n; i++) 22 { 23 scanf("%d",&a[i]); 24 } 25 sort(a+1,a+1+n,cmp); 26 27 ans=0; 28 29 for(int i=1; i<=n; i++) 30 { 31 int x=-1,y=-1,z=-1; 32 for(int j=i+1; j<=n; j++) 33 { 34 for(int k=j+1; k<=n; k++) 35 { 36 if(vis[i]==0&&vis[j]==0&&vis[k]==0) 37 { 38 if(a[i]*3+a[j]*2+a[k]>=m) 39 { 40 x=i; 41 y=j; 42 z=k; 43 } 44 } 45 } 46 } 47 if(x==-1) 48 { 49 break; 50 } 51 else 52 { 53 ans++; 54 vis[x]=1; 55 vis[y]=1; 56 vis[z]=1; 57 } 58 } 59 printf("%d ",ans); 60 memset(vis,0,sizeof(vis)); 61 } 62 return 0; 63 }
D题:Team Name
暴力就行了
bfs枚举字母的每一种方式,然后再分别比较就行了。。。
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int n; 6 char a[105][35]; 7 char ans[105]; 8 bool flag; 9 void dfs(int dep,int len) 10 { 11 if(len==dep) 12 { 13 ans[len++] = '