Submission #1358496


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>
#include <deque>
#include <stdio.h>
#include <limits>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

struct Date {

   const int Days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
   const string Week[7] =  {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
   int year, month, day;
   Date (int y, int m, int d) : year(y), month(m), day(d) {}

   bool isLeapYear(void){
      if (year % 400 == 0)return true;
      if (year % 100 == 0)return false;
      if (year % 4 == 0)return true;
      return false;
   }

   void next_day(void) {
      if (day < Days[month]) day++;
      else if (month == 2 && isLeapYear() && day == 28) day++;
      else if (month == 12) year++, month = 1 ,day = 1;
      else month++, day = 1;
   }

   void previous_day(void) {
    if (day > 1) day--;
    else if (month == 1) year--, month = 12, day = 31;
    else if (month == 3 && isLeapYear()) month--, day = 29;
    else month--, day = Days[month];
   }

   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 * month +  8) / 5 + day) % 7];
   }

   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;
   }

};

int main() {

  int y,m,d; cin >> y >> m >> d;

  Date now(y,m,d);
  Date target(2014,5,17);

  int ans = 0;
  while(true) {
    if(now == target) break;
    ans++;
    now.next_day();
  }

  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task A - 経過日数
User kosakkun
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2455 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 24
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 2 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 2 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 2 ms 256 KB
subtask1_08.txt AC 2 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 2 ms 256 KB
subtask1_11.txt AC 2 ms 256 KB
subtask1_12.txt AC 1 ms 256 KB
subtask1_13.txt AC 2 ms 256 KB
subtask1_14.txt AC 1 ms 256 KB
subtask1_15.txt AC 1 ms 256 KB
subtask1_16.txt AC 2 ms 256 KB
subtask1_17.txt AC 2 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask1_20.txt AC 2 ms 256 KB