Submission #238827

#TimeUsernameProblemLanguageResultExecution timeMemory
238827Exile_2k4Datum (COCI20_datum)C++17
50 / 50
11 ms512 KiB
#include <bits/stdc++.h> using namespace std; int days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; #define year tuple<int,int,int> signed main(){ // freopen("datum.inp","r",stdin); // freopen("datum.out","w",stdout); int n; scanf("%d",&n); set<year> s; for(int mm=1;mm<=12;++mm){ for(int dd=1;dd<=days[mm];++dd){ string d,m; if(dd<10) d+="0"; if(mm<10) m+="0"; d+=to_string(dd),m+=to_string(mm); string yy = d+m; reverse(begin(yy),end(yy)); if(dd==29 && stoi(yy)%4) continue; s.insert({stoi(yy),mm,dd}); } } for(int i=0;i<n;++i){ int d,m,y; scanf("%d.%d.%d.",&d,&m,&y); auto pick = s.lower_bound({y,m,d}); if(make_tuple(y,m,d)==*pick) pick = next(pick); auto ans = *pick; printf("%02d.%02d.%04d.\n",get<2>(ans),get<1>(ans),get<0>(ans)); } }

Compilation message (stderr)

datum.cpp: In function 'int main()':
datum.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
datum.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d.%d.%d.",&d,&m,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...