# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845148 |
2023-09-06T12:16:36 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
111 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
array<int, 12> m={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
auto month = [&](int l)-> int{
string s=to_string(l);
while(s.size()<4) s="0"+s;
int mont= (s[1]-'0')*10 + (s[0]-'0');
return mont;
};
auto day = [&](int l) ->int{
string s=to_string(l);
while(s.size()<4) s="0"+s;
int da = (s[3]-'0')*10+(s[2]-'0');
return da;
};
auto va = [&](int l) -> bool{
int da = day(l);
int mont = month(l);
if(mont>12 || mont==0) return 0;
if(da==0) return 0;
if(mont == 2 && l%4==0){
if(da<=29) return 1;
}
if(m[mont-1]<da) return 0;
return 1;
};
auto anss = [&](int l) -> vector<char>{
string s=to_string(l);
while(s.size()<4) s="0"+s;
vector<char> ans;
ans.push_back(s[3]);
ans.push_back(s[2]);
ans.push_back('.');
ans.push_back(s[1]);
ans.push_back(s[0]);
ans.push_back('.');
for(int i=0; i<4; i++) ans.push_back(s[i]);
ans.push_back('.');
return ans;
};
int t; cin >> t;
while(t--){
string s; cin >> s;
int val=(s[6]-'0')*1000+(s[7]-'0')*100+(s[8]-'0')*10+(s[9]-'0');
int dai= (s[0]-'0')*10+(s[1]-'0');
int moi=(s[3]-'0')*10+(s[4]-'0');
for(int i=val; i<10000; i++){
if(va(i)&& (i!=val ||( moi < month(i) || (moi== month(i) && dai <day(i))))){
auto c = anss(i);
for(auto i: c) cout<<i;
cout<<"\n";
break;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
90 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
111 ms |
344 KB |
Output is correct |