結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
tkmst201
|
| 提出日時 | 2021-01-08 12:24:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,196 bytes |
| コンパイル時間 | 1,815 ms |
| コンパイル使用メモリ | 191,252 KB |
| 最終ジャッジ日時 | 2025-01-17 10:39:30 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d/%d/%d", &y, &m, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//
int main() {
int y, m, d;
scanf("%d/%d/%d", &y, &m, &d);
auto isleap = [](int y) {
if (y % 4 != 0) return false;
if (y % 400) return true;
if (y % 100) return false;
return true;
};
auto add = [isleap](int & y, int & m, int & d) {
if (d == 31 || (d == 30 && (m == 4 || m == 6 || m == 9 || m == 11))) { ++m; d = 1; }
else if (m == 2) {
if (d == 29) { ++m; d = 1; }
else if (d == 28) {
if (isleap(y)) ++d;
else { ++m; d = 1; }
}
else ++d;
}
else ++d;
if (m == 13) { ++y; m = 1; }
};
REP(i, 2) add(y, m, d);
printf("%04d/%02d/%02d\n", y, m, d);
}
tkmst201