제출 #845104

#제출 시각아이디문제언어결과실행 시간메모리
845104vjudge1Datum (COCI20_datum)C++17
0 / 50
51 ms548 KiB
#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 va = [&](int l) -> bool{ string s=to_string(l); while(s.size()<4) s="0"+s; int day = (s[3]-'0')*10+(s[2]-'0'); int month = (s[1]-'0')*10 + (s[0]-'0'); if(month>12 || month==0) return 0; if(month == 2 && l%4==0){ if(day<=29&&day>0) return 1; } if(m[month-1]<day) return 0; if(day == 0) 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; }; for(int i=0; i<10000; i++){ if(va(i)){ auto c = anss(i); for(auto i: c) cout<<i; cout<<"\n"; } } int t; cin >> t; while(t--){ string s; cin >> s; array<int, 12> m={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; auto va = [&](int l) -> bool{ string s=to_string(l); while(s.size()<4) s="0"+s; int day = (s[3]-'0')*10+(s[2]-'0'); int month = (s[1]-'0')*10 + (s[0]-'0'); if(month>12 || month==0) return 0; if(month == 2 && l%4==0){ if(day<=28) return 1; } if(m[month-1]<day) return 0; if(day == 0) 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 val=(s[6]-'0')*1000+(s[7]-'0')*100+(s[8]-'0')*10+(s[9]-'0'); for(int i=val+1; i<10000; i++){ if(va(i)){ auto c = anss(i); for(auto i: c) cout<<i; cout<<"\n"; break; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...