답안 #218285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218285 2020-04-01T19:43:04 Z dolphingarlic Datum (COCI20_datum) C++14
50 / 50
11 ms 640 KB
/*
COCI 2020 Datum
- Ew
- Just do it
*/

#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
 
struct Date {
    int d, m, y, t;
};
 
bool operator<(Date A, Date B) {
    if (A.y == B.y) {
        if (A.m == B.m) {
            if (A.d == B.d) return A.t < B.t;
            return A.d < B.d;
        }
        return A.m < B.m;
    }
    return A.y < B.y;
}
 
int lim[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
vector<Date> palindromes;
 
int main() {
    FOR(i, 0, 4) FOR(j, 0, 10) FOR(k, 0, 2) FOR(l, 0, 10) {
        if (10 * k + l > 0 && 10 * k + l < 13 && 10 * i + j > 0 && 10 * i + j <= lim[10 * k + l - 1] + ((10 * j + i) % 4 == 0 && 10 * k + l == 2))
            palindromes.push_back({10 * i + j, 10 * k + l, 1000 * l + 100 * k + 10 * j + i, 0});
    }
    sort(palindromes.begin(), palindromes.end());
 
    int n;
    scanf("%d", &n);
    while (n--) {
        Date q;
        scanf("%2d.%2d.%4d.", &q.d, &q.m, &q.y);
        Date nxt = *upper_bound(palindromes.begin(), palindromes.end(), q);
        printf("%02d.%02d.%04d.\n", nxt.d, nxt.m, nxt.y);
    }
    return 0;
}

Compilation message

datum.cpp: In function 'int main()':
datum.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
datum.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%2d.%2d.%4d.", &q.d, &q.m, &q.y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 11 ms 640 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 10 ms 512 KB Output is correct