답안 #238628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238628 2020-06-12T08:23:57 Z Vankeca Datum (COCI20_datum) C++14
0 / 50
37 ms 512 KB
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
char day1[2], month1[2], year1[4], day2[2], month2[2], year2[4];
int d1,m1,yne1;
///----------------------------------------------
void read()
{
	char dot;
	cin>>day1[0]>>day1[1];
	cin>>dot;
	cin>>month1[0]>>month1[1];
	cin>>dot;
	cin>>year1[0]>>year1[1]>>year1[2]>>year1[3];
}
///----------------------------------------------
void convert_st()
{
	d1=int(day1[0]-'0')*10+int(day1[1]-'0');
	m1=int(month1[0]-'0')*10+int(month1[1]-'0');
	yne1=int(year1[0]-'0')*1000+int(year1[1]-'0')*100+int(year1[2]-'0')*10+int(year1[3]-'0');
}
///----------------------------------------------
void construct_date(int y)
{
	int i=3;
	while(y>=0 && i>=0)
	{
		year2[i]=char(y%10+'0');
		y/=10;
		i--;
	}
	day2[0]=year2[3]; day2[1]=year2[2];
	month2[0]=year2[1]; month2[1]=year2[0];
	//cout<<day2[0]<<day2[1]<<"."<<month2[0]<<month2[1]<<"."<<year2[0]<<year2[1]<<year2[2]<<year2[3]<<endl;
}
///----------------------------------------------
int convert_dec(int k)
{
	if(k==1)
	{
		return int(day2[0]-'0')*10+int(day2[1]-'0');
	}
	if(k==2)
	{
		return int(month2[0]-'0')*10+int(month2[1]-'0');
	}
	if(k==3)
	{
		return int(year2[0]-'0')*1000+int(year2[1]-'0')*100+int(year2[2]-'0')*10+int(year2[3]-'0');
	}
}
///----------------------------------------------
bool check()
{
	int d=convert_dec(1), m=convert_dec(2), y=convert_dec(3);
	if(d==0 || m==0)return false;
	if(d>31 || m>12)return false;
	if(d==31 && (m==2 || m==4 || m==6 || m==9 || m==11))return false;
	if(d==29 && m==2)
	{
		if(y%4!=0)return false;
	}
	if(d<=d1 && m<=m1 && y==yne1)return false;
	return true;
}
///----------------------------------------------
void solve()
{
	convert_st();
	construct_date(yne1);
	int i=yne1;
	while(check()==false)
	{
		i++;
		construct_date(i);
	}
	cout<<day2[0]<<day2[1]<<"."<<month2[0]<<month2[1]<<"."<<year2[0]<<year2[1]<<year2[2]<<year2[3]<<endl;
}
///----------------------------------------------
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin>>n;
	while(n--)
	{
		read();
		solve();
	}

	return 0;
}

Compilation message

datum.cpp: In function 'int convert_dec(int)':
datum.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Incorrect 37 ms 512 KB Output isn't correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Incorrect 5 ms 384 KB Output isn't correct
8 Incorrect 4 ms 384 KB Output isn't correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Incorrect 35 ms 512 KB Output isn't correct