2009.06.02 11:45 neoevoke Edit
#include #include #include using namespace std; int days[13]={0,31,29,31,30,31,0,31,31,30,31,30,31}; typedef vector VI; VI end; map cache; int getDays(VI today) { if(today[1]!=2) return days[2]; if(today[0]%400==0 || today[0]%100!=0&&today[0]%4==0) return 29; return 28; } VI getNextMonth(VI today) { today[1]++; if(today[1]>12) { today[0]++; today[1]=1; } if(getDays(today)getDays(today)) { today[2]=1; today[1]++; if(today[1]>12) { today[0]++; today[1]=1; } } return today; } int chkWin(VI today) { if(today.empty()) return 1; if(today==end) return 0; if(today>end) return 1; if(cache.count(today)) return cache[today]; int &ret = cache[today]; if(!chkWin(getNextMonth(today)) || !chkWin(getNextDay(today))) ret=1; else ret=0; return ret; } int main() { end.resize(3); end[0]=2001; end[1]=11; end[2]=4; int cases; cin >> cases; while(cases--) { VI test(3); cin >> test[0] >> test[1] >> test[2]; if(chkWin(test)) cout << "YES" << endl; else cout << "NO" << endl; } }
neoevoke소셜계의 김성모