답안 #845081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845081 2023-09-06T11:52:48 Z vjudge1 Datum (COCI20_datum) C++17
0 / 50
3 ms 348 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

bool check(int a, int b, int c, string &str)
{
    bool ok = true;
    if(b <= 0 || 13 <= b) ok = false;
    else if(b == 2) ok &= (1 <= a && a <= 28 + (c % 4 == 0));
    else if(b <= 6) ok &= (1 <= a && a <= 30 + (b & 1));
    else ok &= (1 <= a && 30 + !(b & 1));
    if(!ok) return false;

    int val = 0;
    for(int i = 6; i <= 9; i++) val = val * 10 + str[i] - '0';
    if(val == c)
    {
        val = 0;
        for(int i = 3; i <= 4; i++) val = val * 10 + str[i] - '0';
        if(val > b) return false;
        else if(val == b)
        {
            val = 0;
            for(int i = 0; i <= 1; i++) val = val * 10 + str[i] - '0';
            if(val < a) return true;
            return false;
        } 
        else return true;
    }
    if(b == 2) return a <= 28 + (c % 4 == 0);
    if(b <= 6) return a <= 30 + (b & 1);
    return a <= 30 + !(b & 1);
}

void solve()
{
    string str; cin >> str;
    int val = 0;
    for(int i = 6; i <= 9; i++) val = val * 10 + str[i] - '0';

    for(int k = val; k <= 9999; k++)
    {
        int first = 0;
        int _k = k;
        for(int i = 9; i >= 8; i--) first = first * 10 + _k % 10, _k /= 10;
    
        int second = 0;
        for(int i = 7; i >= 6; i--) second = second * 10 + _k % 10, _k /= 10;

        if(check(first, second, k, str))
        {
            if(first < 10) cout << 0;
            cout << first << '.';
            if(second < 10) cout << 0;
            cout << second << '.';
            if(k < 0) cout << 0;
            if(k < 10) cout << 0;
            if(k < 100) cout << 0;
            if(k < 1000) cout << 0;
            cout << k << '.';
            cout << "\n";
            return;
        }
    }

    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; cin >> t;
    while(t--)
    {
        solve();
    }
}

Compilation message

datum.cpp: In function 'int32_t main()':
datum.cpp:8:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     #define OPEN freopen(".in", "r", stdin); \
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~
datum.cpp:80:5: note: in expansion of macro 'OPEN'
   80 |     OPEN;
      |     ^~~~
datum.cpp:9:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |                  freopen(".out", "w", stdout);
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
datum.cpp:80:5: note: in expansion of macro 'OPEN'
   80 |     OPEN;
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Incorrect 2 ms 344 KB Output isn't correct
3 Incorrect 2 ms 344 KB Output isn't correct
4 Incorrect 2 ms 348 KB Output isn't correct
5 Incorrect 3 ms 344 KB Output isn't correct
6 Incorrect 3 ms 348 KB Output isn't correct
7 Incorrect 2 ms 344 KB Output isn't correct
8 Incorrect 2 ms 344 KB Output isn't correct
9 Incorrect 2 ms 344 KB Output isn't correct
10 Incorrect 3 ms 344 KB Output isn't correct