ccf-Crontab

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<string,int>mp={
    {"jan",1},{"feb",2},{"mar",3},{"apr",4},{"may",5},{"jun",6},
    {"jul",7},{"aug",8},{"sep",9},{"oct",10},{"nov",11},{"dec",12},
    {"sun",0},{"mon",1},{"tue",2},{"wed",3},{"thu",4},{"fri",5},{"sat",6}
};
int get(int y,int m,int d){
	if(m==1||m==2){
		m+=12;
		y-=1;
	}
	int temp=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7+1;
	if(temp==7)return 0;
	else return temp;
}
struct po{
	ll time;
	string con;
	int id;
	po(ll x,string y,int d){
		time=x;
		con=y;
		id=d;
	}
	bool operator<(const po&A)const{
	   if(time!=A.time)return time<A.time;
	   else return id<A.id;
	}
};
int mdays[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
const int yy=(int)1e8,mm=(int)1e6,rr=10000,hh=100;
vector<po>ans;
vector<string>intemp,intemp1;
set<int>group[6];
string tolow(string x){//转化为小写 	
	for(int i=0;i<x.size();i++)x[i]=tolower(x[i]);
	return x;
}
void tostr(string line,string ch){//以ch分割字符串 
	int t;
	intemp.clear(); 
    for(t = line.find(ch); t != string::npos; t = line.find(ch))
    {
        intemp.push_back(line.substr(0,t));
        line = line.substr(t+1);
    }
    intemp.push_back(line);
    return;
}
void tostr1(string line,string ch){//以ch分割字符串 
	int t;
	intemp1.clear(); 
    for(t = line.find(ch); t != string::npos; t = line.find(ch))
    {
        intemp1.push_back(line.substr(0,t));
        line = line.substr(t+1);
    }
    intemp1.push_back(line);
    return;
}
int countdays(int y,int m){
	if((y%400==0||(y%4==0&&y%100!=0))&&m==2)
		return 29;
	 return mdays[m];
}
ll b,e;
int n;
void initgruop(){
	for(int i=1;i<=5;i++){
		group[i].clear();
	}
}
int main(){
	cin>>n>>b>>e;
	string scon;
	for(int i=1;i<=n;i++){
		initgruop();
		for(int j=1;j<=5;j++){
			string ip;
			cin>>ip;
			tostr(ip,",");
			for(int k=0;k<intemp.size();k++){
				tostr1(intemp[k],"-");
				int bx,by;
			    if(intemp1[0]=="*"){
					if(j==1){
						bx=0;by=59;
					}else if(j==2){
						bx=0;by=23;
					}else if(j==3){
						bx=1;by=31;
					}else if(j==4){
						bx=1;by=12;
					}else{
						bx=0;by=6;
					}
				//	cout<<bx<<" "<<by<<" bx by "<<endl; 
					for(int hh=bx;hh<=by;hh++){
					   group[j].insert(hh);
				    }
				    continue;
				}
				if(intemp1.size()==1){
					if(!isdigit(intemp1[0][0])){
						bx=by=mp[tolow(intemp1[0])];
					}else{
						bx=by=stoi(intemp1[0]); 
					} 
				}
				else if(intemp1.size()==2){
					if(!isdigit(intemp1[0][0])){
						bx=mp[tolow(intemp1[0])];
					}else{
						bx=stoi(intemp1[0]);
					}
					if(!isdigit(intemp1[1][0])){
						by=mp[tolow(intemp1[1])];
					}else{
						by=stoi(intemp1[1]);
					}
				}
		    //cout<<bx<<" "<<by<<" bx by "<<endl; 
				for(int hh=bx;hh<=by;hh++){
					group[j].insert(hh);
				}
			} 
		}
		cin>>scon;
	    for(int y=b/yy;y<=e/yy;y++){
	    	for(auto m:group[4]){
	    		for(auto d:group[3]){
	    			if(countdays(y,m)<d)continue;
	    			for(auto xq:group[5]){
	    				if(get(y,m,d)==xq){
	    				   for(auto hours:group[2]){
	    				   	for(auto mi:group[1]){
	    				   		ll temp=(ll)y*yy+m*mm+d*rr+hours*hh+mi;
	    				   		if(temp>=b&&temp<e)ans.push_back(po(temp,scon,i));
							   }
						   }
						   break; 
						}
					}
				}
			}
		} 	
	}
	sort(ans.begin(),ans.end());
	for(auto it:ans){
		cout<<it.time<<" "<<it.con<<endl;
	}
	return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值