結果

問題 No.652 E869120 and TimeZone
ユーザー DameningenDameningen
提出日時 2018-02-24 03:52:58
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,593 bytes
コンパイル時間 6,926 ms
コンパイル使用メモリ 103,552 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-02 05:24:35
合計ジャッジ時間 5,102 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,504 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  int a, b;
  string s;

  cin >> a >> b;
  cin >> s;

  int h = 0, m = 0;
  if (s[3] == '+') {
    if (s.size() == 5) {
      h = int(s[4]-'0') - 9;
    } else if (s.size() == 6) {
      h = int(s[4]-'0')*10 + int(s[5]-'0') - 9;
    } else if (s.size() == 7) {
      h = int(s[4]-'0') - 9;
      m = int(s[6]-'0') * 6;
    } else {
      h = int(s[4]-'0')*10 + int(s[5]-'0') - 9;
      m = int(s[7]-'0') * 6;
    }
  } else if (s[3] == '-') {
    if (s.size() == 5) {
      h = -int(s[4]-'0') - 9;
    } else if (s.size() == 6) {
      h = -int(s[4]-'0')*10 - int(s[5]-'0') - 9;
    } else if (s.size() == 7) {
      h = -int(s[4]-'0') - 9;
      m = -int(s[6]-'0') * 6;
    } else {
      h = -int(s[4]-'0')*10 - int(s[5]-'0') - 9;
      m = -int(s[7]-'0') * 6;
    }
  }

  a += h;
  b += m;
  if (b < 0) {
    --a; b = 60 + b;
  } else if (b >= 60) {
    ++a; b %= 60;
  }

  if (a < 0) {
    a = 24 + a;
  } else if (a >= 24) {
    a %= 24;
  }

  printf("%02d:%02d\n", a, b);

  return 0;
}
0