# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570428 | NekoRolly | Datum (COCI20_datum) | C++17 | 5 ms | 340 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;
typedef long long ll;
const int N = 2e3+4;
struct fecha{
int d,m,a;
};
bool operator<(fecha a,fecha b){
return (a.a != b.a ? a.a < b.a : a.m != b.m ? a.m < b.m : a.d < b.d);
}
int q;
string s;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<fecha> v;
void read(int &x){ x = 0;
for (char c=getchar(); '0'<=c && c<='9'; c = getchar())
x = x*10 + (c - '0');
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
for (int d1=0; d1<=9; d1++) for (int d2=0; d2<=9; d2++)
for (int d3=0; d3<=9; d3++) for (int d4=0; d4<=9; d4++){
int d = d4*10 + d3, m = d2*10 + d1, a = d1*1000 + d2*100 + d3*10 + d4;
if (0 < m && m < 13 && 0 < d && d <= days[m] + (a%4 == 0 && m == 2))
v.push_back({d, m, a});
}
read(q);
for (fecha x; q; q--){ read(x.d), read(x.m), read(x.a); getchar();
int i = 0;
while (!(x < v[i])) i++;
if (v[i].d < 10) cout << "0"; cout << v[i].d << ".";
if (v[i].m < 10) cout << "0"; cout << v[i].m << ".";
if (v[i].a < 10) cout << "000";
if (v[i].a < 100) cout << "00";
if (v[i].a < 1000) cout << "0"; cout << v[i].a << ".\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |