Submission #845657

#TimeUsernameProblemLanguageResultExecution timeMemory
845657vjudge1Datum (COCI20_datum)C++17
40 / 50
15 ms600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back const int inf = 100000000000000000LL; string int_to_str(ll a, ll di) { string ans=""; for(int i = 0; i < di; ++i) { ans+=((char) (((ll)('0')) + a%10)); a/=10; } reverse(ans.begin(),ans.end()); return ans; } ll day(ll x) { ll d1=x/10; ll d2=x%10; return (10*d2+d1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll T; cin >> T; vector<ll> lim{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; vector<ll> a; for(int i = 0; i < 10000; ++i) { ll m=day(i/100); if(m>12 || m==0) {continue;} ll d=day(i%100); if(d==0 || d>lim[m-1]) {continue;} if(m==2 && d==29 && i%4!=0) {continue;} a.pb(d+100*m+10000*i); } for(int t = 0; t < T; ++t) { string s; cin>>s; vector<ll> digits; for(int i = 0; i < s.size(); ++i) { if(s[i]=='.') {continue;} digits.pb((ll) (s[i]-'0')); } ll y=1000*digits[4]+100*digits[5]+10*digits[6]+digits[7]; ll m=10*digits[2]+digits[3]; ll d=10*digits[0]+digits[1]; ll v=10000*y+100*m+d; ll ans=*upper_bound(a.begin(),a.end(),v); d=ans%100; ans/=100; m=ans%100; ans/=100; y=ans; cout << int_to_str(d,2) << "." << int_to_str(m,2) << "." << int_to_str(y,4) << "." << endl; } return 0; }

Compilation message (stderr)

datum.cpp:5:18: warning: overflow in conversion from 'long long int' to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow]
    5 | const int inf =  100000000000000000LL;
      |                  ^~~~~~~~~~~~~~~~~~~~
datum.cpp: In function 'int main()':
datum.cpp:46:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int i = 0; i < s.size(); ++i)
      |                        ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...