奋斗群群赛10---次次诡异
来源:互联网 发布:河北广电网络集团招聘 编辑:程序博客网 时间:2024/05/16 02:05
奋斗群群赛10—次次诡异
- 奋斗群群赛10次次诡异
- T1Chess Tourney
- 题目位置
- 题意
- AC代码
- 小反思无
- T2Luba And The Ticket
- 题目位置
- 题意
- 小反思
- T3Two TVs
- 题目位置
- 题意
- AC代码
- 小反思
- T4Driving Test
- 题目位置
- 题意
- AC代码系统自带栈
- AC代码手写栈
- 总结
- T1Chess Tourney
T1:Chess Tourney
题目位置:
T1位置所在
题意:
就是有n个数,你能否保证对半分之后,子集A的任意元素都能够比子集B的元素大,输出YES,不然输出NO!
AC代码
#include <bits/stdc++.h>using namespace std;const int N= 105;int a[N],b[N];int main(){ int n; scanf("%d",&n); for(int i=1; i<=n*2; i++) { scanf("%d",&a[i]); } sort(a+1,a+1+2*n); if(a[n+1]>a[n]) cout<<"YES"; else cout<<"NO"; return 0;}
小反思:无
T2:Luba And The Ticket
题目位置:
T2位置所在
题意:
问你将一个数经过多少次改变才能使得s1+s2+s3=s4+s5+s6;
输出最少操作次数,可以六重暴力枚举!
#include <bits/stdc++.h>using namespace std;int main(){ string s; cin>>s; int tot=4; for(int a=0; a<=9; a++) for(int b=0; b<=9; b++) for(int c=0; c<=9; c++) for(int d=0; d<=9; d++) for(int e=0; e<=9; e++) for(int f=0; f<=9; f++) { if(a+b+c==e+f+d) { int ans=0; if(a+48!=s[0]) ans++; if(b+48!=s[1]) ans++; if(c+48!=s[2]) ans++; if(d+48!=s[3]) ans++; if(e+48!=s[4]) ans++; if(f+48!=s[5]) ans++; if(ans<tot) tot=ans; } } cout<<tot<<endl;}
小反思:
就是十分美丽的”暴力”!
T3:Two TVs
题目位置
T3位置所在
题意:
就是主要问你给你n组数据,每个节目表示了开始时间和结束时间,就是问你有2台电视,问你能不能够将所有的电视节目分别在2个电脑上出现就好了!但是直达注意到的一点就是如果一个电视节目在时间 5 的位置结束,那么5的时间将不能将别的电视节目装进来,问你能不能够办到?输出YES or NO!
AC代码
#include <bits/stdc++.h>using namespace std;const int N=2000005;struct tv{ int start,end;} t[N];int book[N],a[N],b[N],line[N*10];bool com(tv x,tv y){ return x.start<y.start; return x.end<y.end;}int main(){ int n,end=-1,tot; scanf("%d",&n); tot=n; for(int i=1; i<=n; i++) { scanf("%d%d",&t[i].start,&t[i].end); if(t[i].end>end) end=t[i].end; } sort(t+1,t+1+n,com); int head1=1,head2=1; a[head1]=b[head2]=-1; for(int i=1; i<=n; i++) { if(t[i].start>a[head1]) { head1++; a[head1]=t[i].end; book[i]=1; continue; } if(t[i].start>b[head2]) { head2++; b[head2]=t[i].end; book[i]=1; } } int flag=0; for(int i=1; i<=n; i++) { if(book[i]==0) { flag=1; break; } } if(flag==0) { printf("YES"); } else printf("NO"); return 0;}
小反思:
这题深刻的让我知道了不初始化的严重性 , 因为如果没有这个
a[head1]=b[head2]=-1;
那么就是会有一个数据点电视是 0 点开始的,那么就不会收纳进去!所以一直在WA第5个点,十分的伤心!
T4:Driving Test
题目位置:
T4问题所在
题意:
就是开车时会有n个数据显示汽车的状态,问你有多少次的可能使得这个车能够顺利的不违章的过去!
1.Polycarp changes the speed of his car to specified (this event comes with a positive integer number);
2.Polycarp’s car overtakes the other car;
3.Polycarp’s car goes past the “speed limit” sign (this sign comes with a positive integer);
4.Polycarp’s car goes past the “overtake is allowed” sign;
5.Polycarp’s car goes past the “no speed limit”;
6.Polycarp’s car goes past the “no overtake allowed”;
AC代码(系统自带栈):
#include <bits/stdc++.h>using namespace std;stack <int> my_stack;const int N=1000005;//int tp[N],top;int main(){ int n,x,time,speed,rule=0; scanf("%d",&n); my_stack.push(9999999); int tot=0; for(int i=1; i<=n; i++) { cin>>time; //输入速度 if(time==1) cin>>speed; //超车的时候 if(time==2) { //拆除表示叫你不要超车的标识 tot+=rule; rule=0; } if(time==3) { //路过限速 cin>>x; my_stack.push(x); } //可以飙车! if(time==4) { rule=0; } if(time==5) { my_stack.push(9999999); } if(time==6) { //经过超车的时候将其++ //但是不好说明 2个 6的时候的情况 rule++; } //相当于是在建一个栈的操作! while(speed>my_stack.top()) { my_stack.pop(); tot++; } } cout<<tot<<endl; return 0;}
AC代码(手写栈):
#include <bits/stdc++.h>using namespace std;const int N=1000005;int tp[N],top;int main(){ int n,x,time,speed,rule=0; scanf("%d",&n); tp[0]=99999999; int tot=0; for(int i=1; i<=n; i++) { cin>>time; //输入速度 if(time==1) cin>>speed; //超车的时候 if(time==2) { //拆除表示叫你不要超车的标识 tot+=rule; rule=0; } if(time==3) { //路过限速 cin>>x; top++; tp[top]=x; } //可以飙车! if(time==4) { rule=0; } if(time==5) { top++; tp[top]=9999999; } if(time==6) { //经过超车的时候将其++ //但是不好说明 2个 6的时候的情况 rule++; } //相当于是在建一个栈的操作! while(speed>tp[top]) { top--; tot++; } } cout<<tot<<endl; return 0;}
总结:
1.就是数据初始化的问题导致
2.学会简化问题
3.不去紧张和看重Rank比分!
- 奋斗群群赛10---次次诡异
- 瓮幽砍雅宜刮目潭彼谖坪坪瞎次次
- xjoi奋斗群群赛10
- 第五次次C++实验
- 奋斗群群赛10总结与心得
- 诡异
- 诡异
- 诡异
- xjoi奋斗群群赛2
- 奋斗群群赛---3 渐入佳境
- xjoi奋斗群群赛3
- xjoi奋斗群群赛4
- 奋斗群群赛---4
- xjoi奋斗群群赛5
- 奋斗群群赛---5
- xjoi奋斗群群赛6
- 奋斗群群赛---6
- 奋斗群群赛---7
- C#、Oracle、Sql server中拼音查询的函数
- 0916 T4 赛小城学数学
- PAT 甲级 1016. Phone Bills (25)
- 华为中级机试题--二分查找树的应用
- HDU 1753 大明A+B java大数
- 奋斗群群赛10---次次诡异
- 第二周项目 1 -函数参数传递的三种方式
- eclipse中配置DTD验证
- python 文件查操作汇总
- python继承
- win10 itunes更新ios系统异常 提示“未能恢复iPhone 发生未知错误(14)”
- ubuntu 安装最新系列的 Nvidia GTX 独立显卡
- vue with zTree
- XPath简单教程