結果
| 問題 |
No.652 E869120 and TimeZone
|
| コンテスト | |
| ユーザー |
Ikom
|
| 提出日時 | 2018-02-23 22:52:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 879 bytes |
| コンパイル時間 | 1,657 ms |
| コンパイル使用メモリ | 157,856 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 15:57:09 |
| 合計ジャッジ時間 | 2,824 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 3 |
| other | AC * 27 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:25: warning: ‘h’ may be used uninitialized [-Wmaybe-uninitialized]
26 | if (s[3] == '-') {h *= -1; m *= -1;}
| ~~^~~~~
main.cpp:16:9: note: ‘h’ was declared here
16 | int h,m;
| ^
main.cpp:26:34: warning: ‘m’ may be used uninitialized [-Wmaybe-uninitialized]
26 | if (s[3] == '-') {h *= -1; m *= -1;}
| ~~^~~~~
main.cpp:16:11: note: ‘m’ was declared here
16 | int h,m;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
string s;
cin >> a >> b >> s;
string t = s.substr(4);
int h,m;
bool flag = false;
for (int i = 0;i < t.size();i++){
if (i == 0) h = t[i] - '0';
else if (t[i] == '.') flag = true;
else if (flag) m = (t[i] - '0') * 6;
else {h *= 10;h += t[i] - '0';}
}
if (s[3] == '-') {h *= -1; m *= -1;}
a += h - 9;
b += m;
if (b >= 60) {
a += b/60;
b %= 60;
}
if (b < 0) {
a += b/60 - 1;
b += 60*(-b/60 + 1);
}
if (a >= 24) {
a = a-24;
}
if (a < 0) a += 24;
if (a < 10) cout << '0' << a << ':' ;
else cout << a << ':' ;
if (b < 10) cout << '0' << b << endl;
else cout << b << endl;
return 0;
}
Ikom