QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834121 | #3416. First Date | SGColin# | AC ✓ | 33ms | 61704kb | C++20 | 2.0kb | 2024-12-27 11:31:55 | 2024-12-27 11:31:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define pb push_back
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
constexpr int N = 10000007;
constexpr int num[2][13] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
int d[10000][13][32], Y[N], M[N], D[N];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int yy = 1582, mm = 10, dd = 4, tot = 0;
while (yy <= 9999) {
int isr = (yy % 4 == 0);
while (mm <= 12) {
while (dd <= num[isr][mm]) {
d[yy][mm][dd] = ++tot;
++dd;
}
++mm; dd = 1;
}
++yy; mm = 1;
}
yy = 1582, mm = 10, dd = 15, tot = 0;
while (yy <= 9999) {
int isr = (yy % 400 == 0) || (yy % 100 != 0 && yy % 4 == 0);
while (mm <= 12) {
while (dd <= num[isr][mm]) {
++tot;
Y[tot] = yy;
M[tot] = mm;
D[tot] = dd;
++dd;
}
++mm; dd = 1;
}
++yy; mm = 1;
}
string s;
while (cin >> s) {
dd = (s[8] - '0') * 10 + (s[9] - '0');
mm = (s[5] - '0') * 10 + (s[6] - '0');
yy = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
int id = d[yy][mm][dd];
yy = Y[id];
mm = M[id];
dd = D[id];
printf("%04d-%02d-%02d\n", yy, mm, dd);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 33ms
memory: 57316kb
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-10-02 1665-02-05 1642-03-22 9867-02-22 2202-09-22 3839-09-30 6883-11-08 3518-12-05 8320-02-24 8308-06-20 8470-08-02 7764-10-19 8188-09-14 6485-09-10 7856-01-08 2208-07-06 4641-01-27 5498-08-10 9278-04-07 3798-09-30 9506-05-26 9058-10-24 5489-03-12 7624-05-09 7175-12-30 291...
result:
ok 100000 lines
Test #2:
score: 0
Accepted
time: 31ms
memory: 61704kb
input:
9500-01-01 9500-01-02 9500-01-03 9500-01-04 9500-01-05 9500-01-06 9500-01-07 9500-01-08 9500-01-09 9500-01-10 9500-01-11 9500-01-12 9500-01-13 9500-01-14 9500-01-15 9500-01-16 9500-01-17 9500-01-18 9500-01-19 9500-01-20 9500-01-21 9500-01-22 9500-01-23 9500-01-24 9500-01-25 9500-01-26 9500-01-27 950...
output:
9500-03-12 9500-03-13 9500-03-14 9500-03-15 9500-03-16 9500-03-17 9500-03-18 9500-03-19 9500-03-20 9500-03-21 9500-03-22 9500-03-23 9500-03-24 9500-03-25 9500-03-26 9500-03-27 9500-03-28 9500-03-29 9500-03-30 9500-03-31 9500-04-01 9500-04-02 9500-04-03 9500-04-04 9500-04-05 9500-04-06 9500-04-07 950...
result:
ok 182551 lines
Test #3:
score: 0
Accepted
time: 5ms
memory: 57320kb
input:
1582-10-04 1752-09-02 1900-02-25 1923-02-15
output:
1582-10-15 1752-09-14 1900-03-10 1923-03-01
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 8ms
memory: 59424kb
input:
1700-02-16 1700-02-17 1700-02-18 1700-02-19 1800-02-15 1800-02-16 1800-02-17 1800-02-18 1900-02-14 1900-02-15 1900-02-16 1900-02-17 2100-02-13 2100-02-14 2100-02-15 2100-02-16 2200-02-12 2200-02-13 2200-02-14 2200-02-15 2300-02-11 2300-02-12 2300-02-13 2300-02-14 2500-02-10 2500-02-11 2500-02-12 250...
output:
1700-02-27 1700-02-28 1700-03-01 1700-03-02 1800-02-27 1800-02-28 1800-03-01 1800-03-02 1900-02-27 1900-02-28 1900-03-01 1900-03-02 2100-02-27 2100-02-28 2100-03-01 2100-03-02 2200-02-27 2200-02-28 2200-03-01 2200-03-02 2300-02-27 2300-02-28 2300-03-01 2300-03-02 2500-02-27 2500-02-28 2500-03-01 250...
result:
ok 252 lines
Test #5:
score: 0
Accepted
time: 25ms
memory: 61472kb
input:
1582-10-04 1582-10-05 1582-10-06 1582-10-07 1582-10-08 1582-10-09 1582-10-10 1582-10-11 1582-10-12 1582-10-13 1582-10-14 1582-10-15 1582-10-16 1582-10-17 1582-10-18 1582-10-19 1582-10-20 1582-10-21 1582-10-22 1582-10-23 1582-10-24 1582-10-25 1582-10-26 1582-10-27 1582-10-28 1582-10-29 1582-10-30 158...
output:
1582-10-15 1582-10-16 1582-10-17 1582-10-18 1582-10-19 1582-10-20 1582-10-21 1582-10-22 1582-10-23 1582-10-24 1582-10-25 1582-10-26 1582-10-27 1582-10-28 1582-10-29 1582-10-30 1582-10-31 1582-11-01 1582-11-02 1582-11-03 1582-11-04 1582-11-05 1582-11-06 1582-11-07 1582-11-08 1582-11-09 1582-11-10 158...
result:
ok 189289 lines