# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845107 | vjudge1 | Datum (COCI20_datum) | C++14 | 23 ms | 472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 2e5 + 5;
int arr[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int check(int d, int m, int y){
m--;
if(d == 0) return 0;
if(d <= arr[m]) return 1;
if(d == 29 && m == 1 && y % 4 == 0) return 1;
return 0;
}
inline void solve(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
int year;
year = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
if(s[3] > s[7]){
year++;
}
else if(s[3] < s[7]) year;
else if(s[4] > s[6]) year++;
else if(s[4] < s[6]) year;
else if(s[0] > s[9]) year++;
else if(s[0] < s[9]) year;
else if(s[1] >= s[8]) year++;
int year_in_arr[4];
year_in_arr[0] = year / 1000;
year %= 1000;
year_in_arr[1] = year / 100;
year %= 100;
year_in_arr[2] = year / 10;
year %= 10;
year_in_arr[3] = year;
year = year_in_arr[0] * 1000 + year_in_arr[1] * 100 + year_in_arr[2] * 10 + year_in_arr[3];
while(1){
int d = year_in_arr[3] * 10 + year_in_arr[2];
int m = year_in_arr[1] * 10 + year_in_arr[0];
int y = year;
if(check(d, m, y)){
cout << ((d < 10) ? "0" : "") << d << "." << ((m < 10) ? "0" : "") << m << "." << ((y < 10) ? "000" : ((y < 100) ? "00" : ((y < 1000) ? "0" : ""))) << y << "." << endl;
break;
}
year++;
year_in_arr[3]++;
if(year_in_arr[3] == 10) year_in_arr[3] = 0, year_in_arr[2]++;
if(year_in_arr[2] == 10) year_in_arr[2] = 0, year_in_arr[1]++;
if(year_in_arr[1] == 10) year_in_arr[1] = 0, year_in_arr[0]++;
}
}
}
int main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |