QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#345224 | #3416. First Date | PetroTarnavskyi# | WA | 21ms | 3604kb | C++20 | 1.2kb | 2024-03-06 16:42:45 | 2024-03-06 16:42:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
VI days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool leap(int y)
{
if (y % 400 == 0)
return true;
if (y % 100 == 0)
return false;
if (y % 4 == 0)
return true;
return false;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
assert(accumulate(ALL(days), 0) == 365);
string s;
while (cin >> s)
{
int y = stoi(s.substr(0, 4));
int m = stoi(s.substr(5, 2));
int d = stoi(s.substr(8, 2));
int diff = (y - (m <= 2)) / 100 - (y - (m <= 2)) / 400 - 1;
if (leap(y))
days[1]++;
d += diff;
if (d > days[m - 1])
{
d -= days[m - 1];
m++;
}
if (m > 12)
{
m -= 12;
y++;
}
cout << y << '-';
if (m < 10)
cout << 0;
cout << m << '-';
if (d < 10)
cout << 0;
cout << d << '\n';
if (leap(y))
days[1]--;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 21ms
memory: 3604kb
input:
1998-08-17 4382-11-10 4709-08-28 1665-01-25 1642-03-11 9866-12-11 2202-09-06 3839-09-02 6883-09-19 3518-11-09 8319-12-24 8308-04-19 8470-06-01 7764-08-23 8188-07-16 6485-07-25 7855-11-11 2208-06-20 4640-12-24 5498-07-01 9278-01-29 3798-09-03 9506-03-16 9058-08-18 5489-01-31 7624-03-14 7175-11-07 291...
output:
1998-08-31 4382-12-12 4709-09-32 1665-02-05 1642-03-22 9867-01-53 2202-09-22 3839-09-30 6883-10-39 3518-12-05 8320-01-55 8308-05-51 8470-07-33 7764-09-49 8188-08-45 6485-08-41 7855-12-39 2208-07-06 4641-01-27 5498-08-10 9278-02-66 3798-09-30 9506-04-56 9058-09-54 5489-02-40 7624-04-39 7175-12-30 291...
result:
wrong answer 3rd lines differ - expected: '4709-10-02', found: '4709-09-32'