# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291707 | penguinhacker | Datum (COCI20_datum) | C++14 | 7 ms | 640 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.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
const int d[13]={-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<ar<int, 3>> dates; //year, month, day
string filler(int x, int d) {
int digs=0;
while(x>0) ++digs, x/=10;
return string(d-digs, '0');
}
string To_string(int x) {
string res;
while(x>0) res.push_back(x%10+'0'), x/=10;
reverse(res.begin(), res.end());
return res;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (int i=0; i<10000; ++i) {
int month=i/100; month=month%10*10+month/10;
int day=i%100; day=day%10*10+day/10;
if (month<1||month>12) continue;
int bound=d[month];
if (month==2&&i%4==0) ++bound;
if (day==0||day>bound) continue;
dates.push_back({i, month, day});
//cout << i << "\n";
}
int n;
cin >> n;
for (int i=0; i<n; ++i) {
string s; cin >> s;
int day=atoi(s.substr(0, 2).c_str());
int month=atoi(s.substr(3, 2).c_str());
int year=atoi(s.substr(6, 4).c_str());
int pos=upper_bound(dates.begin(), dates.end(), ar<int, 3>{year, month, day})-dates.begin();
assert(pos<dates.size());
ar<int, 3> cur=dates[pos];
string ans1=filler(cur[2], 2)+To_string(cur[2]);
string ans2=filler(cur[1], 2)+To_string(cur[1]);
string ans3=filler(cur[0], 4)+To_string(cur[0]);
cout << ans1 << "." << ans2 << "." << ans3 << ".\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |