Submission #238827

# Submission time Handle Problem Language Result Execution time Memory
238827 2020-06-13T06:35:37 Z Exile_2k4 Datum (COCI20_datum) C++17
50 / 50
11 ms 512 KB
#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

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 time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 11 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 11 ms 512 KB Output is correct