题目:传送门
思路: 因为数据范围很小,我们可以直接暴力,我们以30天每天都为起点去与所给序列比较,如果存在一天为起点时整个序列都是符合的,那么比较下一天和最后一天的大小就可以了。这里我们要加一个谈判,因为所给序列长度为1时只有0,15能确定位置,其他的都不能确定。
#include <iostream>
using namespace std;
int a[100];
int day[30]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++) {
cin>>a[i];
}
for(int i=0;i<30;i++) {
if(n==1&&a[0]!=15&&a[0]!=0) continue;
int flag = 1;
int now = 0,s = i;
while(flag) {
if(day[s]!=a[now]) flag = 0;
if(now==n-1) break;
now++;
s= (s+1)%30;
}
if(flag ==0) continue;
else {
int m = (s+1)%30;
//cout<<day[m]<<day[s]<<endl;
if(day[m]>day[s]) cout<<"UP"<<endl;
else {
cout<<"DOWN"<<endl;
}
return 0;
}
}
cout<<"-1"<<endl;
return 0;
}