Submission #845313

# Submission time Handle Problem Language Result Execution time Memory
845313 2023-09-06T13:08:41 Z vjudge1 Datum (COCI20_datum) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
#define pb push_back
#define fi first
#define se second
#define CDIV(a,b) (((a)+(b)-(1))/(b))

 
int mod_(int a, int b)
{
    if(a >= 0)return a % b;
    a += (-a/b + 1) * b;
    return a % b;
}


ll to_int(string s) // TEST THIS
{
    int d = stoi(string{s.begin(), s.begin() + 2}), 
        m = stoi(string{s.begin() + 3, s.begin() + 5}),
        y = stoi(string{s.begin() + 6, s.end() - 1});
    return (1e4 * y) + (100 * m) + d;
}

string int_to_str(ll x)
{
    string d = to_string(x % 100),
           m = to_string((x % 10000) / 100),
           y = to_string(x / 10000);
    while(d.size() < 2)d = "0" + d;
    while(m.size() < 2)m = "0" + m;
    while(y.size() < 4)y = "0" + y;
    return d + "." + m + "." + y + ".";
}

int mon[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
bool check(string day, string mo, string ye)
{
    int d = stoi(day), m = stoi(mo), y = stoi(ye);
    if(d < 1 or m < 1)return false;
    if(m == 2 and d == 29 and y % 4)return false;
    if(m > 12)return false;
    if(mon[m - 1] < d)return false;
    return true;
}

set<int>s;

void solve()
{
    for(int i = 0; i < 3000; ++i)
    {
        string y = to_string(i);
        while(y.size() < 4)y = "0" + y;
        reverse(y.begin(), y.end());
        string d{y.begin(), y.begin() + 2},
               m{y.begin() + 2, y.end()};
        reverse(y.begin(), y.end());
        if(check(d, m, y))
        {
            s.insert(to_int(d + "." + m + "." + y + "."));
        }
    }
    int n;
    cin >> n;
    while(n--)
    {
        string a;
        cin >> a;
        int ans = *s.upper_bound(to_int(a));
        cout << int_to_str(ans) << endl;
    }
}
    

int main()
{
    fio;
    //int t; cin >> t; while(t--)
    {
        solve();
    }
}

Compilation message

datum.cpp: In function 'int main()':
datum.cpp:80:5: error: 'fio' was not declared in this scope; did you mean 'fi'?
   80 |     fio;
      |     ^~~
      |     fi