GAME3112 - Ngày 31 tháng 12
Tác giả: skyvn97
Ngôn ngữ: C++
#include<stdio.h>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
ii opt[40][20];
int d,m;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(void)
{
int i,j,k;
scanf("%d",&d);
scanf("%d",&m);
for (j=12;j>=1;j=j-1)
for (i=day[j];i>=1;i=i-1)
{
opt[i][j].first=1;
if ((i==31) && (j==12)) continue;
opt[i][j].first=-1;
for (k=i+1;k<=day[j];k=k+1)
if (opt[k][j].first<0)
{
opt[i][j].first=k;
opt[i][j].second=j;
break;
}
if (opt[i][j].first>0) continue;
for (k=j+1;k<=12;k=k+1)
if (i<=day[k])
if (opt[i][k].first<0)
{
opt[i][j].first=i;
opt[i][j].second=k;
break;
}
}
if (opt[d][m].first<0) printf("LOSS");
else printf("%d %d",opt[d][m].first,opt[d][m].second);
}