https://vjudge.net/problem/UVA-158
uva_presentation error的,poj1209能过
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int f;
int mm[2][12]={{31,29,31,30,31,30,31,31,30,31,30,31}
,{31,28,31,30,31,30,31,31,30,31,30,31}};
struct AA{
int month,day,level,index;
string s;
int operator-(AA& a){
int t=month-a.month;
if(t>1)return 8;
if(t==1)return day-a.day+mm[f][a.month-1];
return day-a.day;
}
}aa;
vector<AA> v;
bool cmp(AA a,AA b){
if(a.month>b.month)return false;
if(a.month<b.month)return true;
if(a.day>b.day)return false;
if(a.day<b.day)return true;
if(a.level>b.level)return true;
if(a.level<b.level)return false;
return a.index<b.index;
}
bool cmp2(AA a,AA b){
if(a.month>b.month)return false;
if(a.month<b.month)return true;
if(a.day>b.day)return false;
if(a.day<b.day)return true;
return true;
}
bool cmp1(AA a,AA b){
return a.index<b.index;
}
bool equal(AA a,AA b){
return a.month==b.month&&a.day==b.day;
}
const char cc[]="*TODAY*";
void print(AA a,int tt){
tt++;
if(tt>0){
printf("%3d%3d ",a.day,a.month);
int j;
for(j=0;j<tt;j++)
putchar('*');
for(;j<8;j++)
putchar(' ');
cout<<a.s<<endl;
}
}
int main(){
int n;
scanf("%d",&n);
f=1;
if((n%400==0)||(n%100!=0&&n%4==0))f=0;
string s;
bool ff=true;
n=0;
while(cin>>s){
if(s=="#")return 0;
if(s=="A"){
scanf("%d%d%d",&aa.day,&aa.month,&aa.level);
char c;
while((c=getchar())==' ');
aa.s="";
aa.s+=c;
string t;
getline(cin,t,'\n');
aa.s+=t;
aa.index=n++;
v.push_back(aa);
continue;
}
if(ff){
ff=false;
sort(v.begin(),v.end(),cmp);
}
scanf("%d%d",&aa.day,&aa.month);
printf("Today is:%3d%3d\n",aa.day,aa.month);
int t=upper_bound(v.begin(),v.end(),aa,cmp2)-v.begin();
vector<AA> vv;
while(v[t].month==aa.month&&v[t].day==aa.day)
vv.push_back(v[t++]);
sort(vv.begin(),vv.end(),cmp1);
for(int i=0;i<vv.size();i++){
printf("%3d%3d %s ",vv[i].day,vv[i].month,cc);
cout<<vv[i].s<<endl;
continue;
}
//cout<<aa.day<<" "<<aa.month<<endl;
for(int i=t;i<v.size();i++){
int tt=v[i]-aa;
/*cout<<v[i].day<<" "<<v[i].month<<" "
<<v[i].level<<" "<<tt<<endl;
*/
if(tt>7)break;
tt=v[i].level-tt;
print(v[i],tt);
}
if(aa.month==12)
for(int i=0;i<v.size();i++){
if(v[i].month==1){
int tt=31+v[i].day-aa.day;
tt=v[i].level-tt;
print(v[i],tt);
}
}
puts("");
}
return 0;
}