Submission #1364307
Source Code Expand
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
typedef long long ll;
struct Date {
int Days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
string Week[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int year, month, day, spend;
Date (int y, int m, int d) : year(y), month(m), day(d) {
spend = julian_day();
}
bool is_leap_year(void){
if (year % 400 == 0)return true;
if (year % 100 == 0)return false;
if (year % 4 == 0)return true;
return false;
}
string get_week(void) {
int m = month, y = year;
if (m < 3) y--, m += 12;
return Week[(y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + day) % 7];
}
int julian_day(void) {
int y = year + 4800, m = month;
if (m < 3) y--, m += 12;
return 365*y + y/4 - y/100 + y/400 + (153*m - 457)/5 + day - 32045;
}
Date operator ++ (int) {
if (day < Days[month]) day++;
else if (month == 2 && is_leap_year() && day == 28) day++;
else if (month == 12) year++, month = 1 ,day = 1;
else month++, day = 1;
spend = julian_day();
return *this;
}
Date operator -- (int) {
if (day > 1) day--;
else if (month == 1) year--, month = 12, day = 31;
else if (month == 3 && is_leap_year()) month--, day = 29;
else month--, day = Days[month];
spend = julian_day();
return *this;
}
bool operator == (const Date &a) const {
if(year == a.year && month == a.month && day == a.day) return true;
return false;
}
bool operator != (const Date &a) const {
if(year == a.year && month == a.month && day == a.day) return false;
return true;
}
bool operator < (const Date &a) const {
return spend < a.spend;
}
int operator - (Date &a) {
spend = julian_day(), a.spend = a.julian_day();
return spend - a.spend;
}
};
int main() {
Date a(0,0,0);
Date t(2014,5,17);
cin >> a.year >> a.month >> a.day;
cout << t - a << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 経過日数 |
User |
kosakkun |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2421 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask0_sample04.txt |
All |
subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask0_sample04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask0_sample01.txt |
AC |
1 ms |
256 KB |
subtask0_sample02.txt |
AC |
1 ms |
256 KB |
subtask0_sample03.txt |
AC |
1 ms |
256 KB |
subtask0_sample04.txt |
AC |
1 ms |
256 KB |
subtask1_01.txt |
AC |
1 ms |
256 KB |
subtask1_02.txt |
AC |
1 ms |
256 KB |
subtask1_03.txt |
AC |
1 ms |
256 KB |
subtask1_04.txt |
AC |
1 ms |
256 KB |
subtask1_05.txt |
AC |
1 ms |
256 KB |
subtask1_06.txt |
AC |
1 ms |
256 KB |
subtask1_07.txt |
AC |
1 ms |
256 KB |
subtask1_08.txt |
AC |
1 ms |
256 KB |
subtask1_09.txt |
AC |
1 ms |
256 KB |
subtask1_10.txt |
AC |
1 ms |
256 KB |
subtask1_11.txt |
AC |
1 ms |
256 KB |
subtask1_12.txt |
AC |
1 ms |
256 KB |
subtask1_13.txt |
AC |
1 ms |
256 KB |
subtask1_14.txt |
AC |
1 ms |
256 KB |
subtask1_15.txt |
AC |
1 ms |
256 KB |
subtask1_16.txt |
AC |
1 ms |
256 KB |
subtask1_17.txt |
AC |
1 ms |
256 KB |
subtask1_18.txt |
AC |
1 ms |
256 KB |
subtask1_19.txt |
AC |
1 ms |
256 KB |
subtask1_20.txt |
AC |
1 ms |
256 KB |