# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
241987 | stev2005 | Datum (COCI20_datum) | C++17 | 36 ms | 532 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<string>
using namespace std;
struct date
{
int day,month,year;
date(){}
date(int _day,int _month,int _year)
{day=_day;month=_month;year=_year;}
void init_year()
{
year=0;
year=year*10+(month%10);
year=year*10+(month/10%10);
year=year*10+(day%10);
year=year*10+(day/10%10);
}
void init_ans(string &s)
{
char c;int t='0';
c=(char)((day/10%10)+t);
s+=c;
c=(char)((day%10)+t);
s+=c;
s+='.';
c=(char)(month/10%10+t);
s+=c;
c=(char)(month%10+t);
s+=c;
s+='.';
c=(char)(year/1000%10+t);
s+=c;
c=(char)(year/100%10+t);
s+=c;
c=(char)(year/10%10+t);
s+=c;
c=(char)(year%10+t);
s+=c;
s+='.';
}
};
const int inf=(1<<20);
string in,ans;
int cury;
void init_in()
{
cury=0;
int t='0';
cury=cury*10+((int)in[6]-t);
cury=cury*10+((int)in[7]-t);
cury=cury*10+((int)in[8]-t);
cury=cury*10+((int)in[9]-t);
}
void solve()
{
int raz=inf;
date curans;
for(int month=1;month<=12;month++)
{
if(month==2)
{
for(int day=1;day<=29;day++)
{
date cur(day,month,0);
cur.init_year();
///cout<<cur.day<<' '<<cur.month<<' '<<cur.year<<endl;
if(cur.year-cury<raz&&cur.year-cury>=0)
{
raz=cur.year-cury;
curans=cur;
///cout<<curans.day<<' '<<curans.month<<' '<<curans.year<<endl;
}
}
}
if(month==4||month==6||month==9||month==11)
{
for(int day=1;day<=30;day++)
{
date cur(day,month,0);
cur.init_year();
///cout<<cur.day<<' '<<cur.month<<' '<<cur.year<<endl;
if(cur.year-cury<raz&&cur.year-cury>=0)
{
raz=cur.year-cury;
curans=cur;
///cout<<curans.day<<' '<<curans.month<<' '<<curans.year<<endl;
}
}
}
else
{
for(int day=1;day<=31;day++)
{
date cur(day,month,0);
cur.init_year();
///cout<<cur.day<<' '<<cur.month<<' '<<cur.year<<endl;
if(cur.year-cury<raz&&cur.year-cury>=0)
{
raz=cur.year-cury;
curans=cur;
///cout<<curans.day<<' '<<curans.month<<' '<<curans.year<<endl;
}
}
}
}
ans="";
curans.init_ans(ans);
///cout<<curans.day<<' '<<curans.month<<' '<<curans.year<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>in;
init_in();
solve();
cout<<ans<<endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |