题解:
还比较有意思的一题,就是给出时分秒,给出人要走的两个时间点(任何一个都可以作为起点和终点,可以顺时针也可以逆时针),问是否可以顺利走完(不碰到时分秒的针)
思路:
我开了120的数组,每2位表示一个刻度(为了处理不是整点的问题),如果分秒都为0,则时针的位置为h*10,否则随便加一个1-9的数字表示不是整点,同理如果秒为0,分针的位置为m*2,否则就为m*2+1,秒针就直接s*2,然后顺时针搞一遍,可以就输出yes,不行就逆时针搞一遍,可以就输出yes,否则就是no
暂时ac代码:
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<math.h>
#include<string>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<deque>
#include<algorithm>
#define ll long long
#define INF 1008611111
#define M (t[k].l+t[k].r)/2
#define lson k*2
#define rson k*2+1
using namespace std;
int vis[125];
int main()
{
int t1,t2,h,m,s,tag=1,st,ed,i;
scanf("%d%d%d%d%d",&h,&m,&s,&t1,&t2);
memset(vis,0,sizeof(vis));
if(h==12)
h=0;
if(m==0&&s==0)
vis[h*10]=1;
else
vis[h*10+5]=1;
if(s==0)
vis[m*2]=1;
else
vis[m*2+1]=1;
vis[s*2]=1;
if(t1>t2)
swap(t1,t2);
st=t1*10;
ed=t2*10;
for(i=st;i<=ed;i++)
{
if(vis[i])
{
tag=0;
break;
}
}
if(tag)
{
printf("YES\n");
return 0;
}
int flag=1;
for(i=ed;i<=120;i++)
{
if(vis[i])
{
flag=0;
break;
}
}
for(i=0;i<=st;i++)
{
if(vis[i])
{
flag=0;
break;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}