2019CSP-J第二轮解题报告
解题报告 浙江师范大学婺州外国语学校 by_xx
在此输入正文
T1 数字游戏
纯放水,四题直接变三题
1. #include <bits/stdc++.h>
2. using namespace std;
3. int ans=0;
4. string s;
5. int main(){
6. cin>>s;
7. for(int i=0;i<s.size();i++)
8. ans+=s[i]=='1'?1:0;
9. cout<<ans<<endl;
10. return 0;
11. }
T2 公交换乘
模拟题,因 ,且 互不相同,数据暴力模拟可以过注意控制游标的控制
当然用队列、优先队列、循环队列等优化会更美,用链表写也很完美,个人感觉很不错的一道
题
1. //优先队列+队列
2. #include <bits/stdc++.h>
3. using namespace std;
4. struct nod{
5. int t,p;
6. friend bool operator < (const nod &x,const nod &y){
7. return x.t>y.t;
评论0