結果
| 問題 |
No.1664 Unstable f(n)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-07 21:02:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,471 bytes |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 107,236 KB |
| 最終ジャッジ日時 | 2025-01-24 08:43:12 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | WA * 1 RE * 37 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d", &T);
| ~~~~~^~~~~~~~~~
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d%d", &h, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d:%d", &t1, &t2);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <ctime>
#include <algorithm>
#include <unordered_map>
using namespace std;
bool can(int x)
{
if (x == 0 || x == 1 || x == 2 || x == 5 || x == 8)
{
return 1;
}
else
return 0;
}
unordered_map<int, int> _hash;
int main()
{
_hash[2] = 5;
_hash[0] = 0;
_hash[5] = 2;
_hash[1] = 1;
_hash[8] = 8;
int T;
scanf("%d", &T);
while (T--)
{
int h, m;
scanf("%d%d", &h, &m);
int t1, t2;
scanf("%d:%d", &t1, &t2);
bool b0 = can(t1 % 10) && can(t1 / 10) && can(t2 % 10) && can(t2 / 10);
if (b0)
{
int newt1 = _hash[(t2 / 10)] + _hash[(t2 % 10)] * 10;
int newt2 = _hash[(t1 / 10)] + _hash[(t1 % 10)] * 10;
bool b2 = newt1 < h && newt2 < m;
if (b2)
{
printf("%02d:%02d\n", t1, t2);
}
else
{
while (1)
{
t2++;
t1 = (t1 + t2 / m) % h;
t2 %= m;
bool b1 = can(t1 % 10) && can(t1 / 10) && can(t2 % 10) && can(t2 / 10);
if (b1)
{
int newt1 = _hash[(t2 / 10)] + _hash[(t2 % 10)] * 10;
int newt2 = _hash[(t1 / 10)] + _hash[(t1 % 10)] * 10;
bool b2 = newt1 < h && newt2 < m;
if (b2)
{
printf("%02d:%02d\n", t1, t2);
break;
}
}
}
}
}
else
{
while (1)
{
t2++;
t1 = (t1 + t2 / m) % h;
t2 %= m;
bool b1 = can(t1 % 10) && can(t1 / 10) && can(t2 % 10) && can(t2 / 10);
if (b1)
{
int newt1 = _hash[(t2 / 10)] + _hash[(t2 % 10)] * 10;
int newt2 = _hash[(t1 / 10)] + _hash[(t1 % 10)] * 10;
bool b2 = newt1 < h && newt2 < m;
if (b2)
{
printf("%02d:%02d\n", t1, t2);
break;
}
}
}
}
}
return 0;
}