Submission #846021

#TimeUsernameProblemLanguageResultExecution timeMemory
846021vjudge1Datum (COCI20_datum)C++17
5 / 50
78 ms592 KiB
#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 #define ONLINE_JUDGE #ifndef ONLINE_JUDGE #define OPEN freopen(".in", "r", stdin); \ freopen(".out", "w", stdout); #else #define OPEN void(23); #endif set <int> vec; int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int toint(string &a) { int val = 0; for(char &ch : a) val = val * 10 + (ch - '0'); return val; } void precalc() { for(int i = 1; i <= 12; i++) { for(int j = 1; j <= months[i]; j++) { string str = (i <= 9 ? "0" : "") + to_string(i) + (j <= 9 ? "0" : "") + to_string(j); reverse(str.begin(), str.end()); int year = toint(str); vec.emplace(year * 10000 + j * 100 + i); } } } void solve() { string date; cin >> date; int day = 0, month = 0, year = 0; for(int i = 1; i <= 2; i++) day = day * 10 + date[0 + i -1] - '0'; for(int i = 1; i <= 2; i++) month = month * 10 + date[3 + i -1] - '0'; for(int i = 1; i <= 4; i++) year = year * 10 + date[6 + i -1] - '0'; auto it = vec.upper_bound(year * 10000 + month * 100 + day); int _year = *it / 10000; int _month = (*it / 100) % 100; int _day = *it % 100; cerr << day << '.' << month << '.' << year << ".\n"; if(_day <= 9) cout << '0'; cout << _day << '.'; if(_month <= 9) cout << '0'; cout << _month << '.'; if(_year <= 9) cout << '0'; if(_year <= 99) cout << '0'; if(_year <= 999) cout << '0'; cout << _year << '.'; cout << "\n"; return; } int32_t main() { OPEN; precalc(); //for(const int &i : vec) cerr << i << " "; ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while(t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...