Submission #845433

# Submission time Handle Problem Language Result Execution time Memory
845433 2023-09-06T13:35:40 Z vjudge1 Datum (COCI20_datum) C++17
0 / 50
877 ms 90260 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()


bool is_palindrome(string s){
	string res=s;
	reverse(all(res));
	return res==s;
}

vector<char> go(int d){
  vector<char> res;
  while(d){
  	res.pb('0'+d%10);
  	d/=10;
  }
  reverse(all(res));
  return res;
}


bool check(int d,int m,int y){
   if(d>31 || m>12) return 0;
   if(m==0 || d==0 || y==0) return 0;
   
   if(m==2){
   	 if(d>29) return 0;
   	 if(y%4!=0 && d==29) return 0; 
   }
   else if(m==4 && d>30) return 0;
   else if(m==6 && d>30) return 0;
   else if(m==9 && d>30) return 0;
   else if(m==11 && d>30) return 0;

   return 1;
}

bool valid(int d,int m,int y){
   string s="";
   vector<char> cur=go(d);
   if(sz(cur)<2) s.pb('0');
   for(char x:cur) s.pb(x);
   cur=go(m);
   if(sz(cur)<2) s.pb('0');
   for(char x:cur) s.pb(x);
   cur=go(y);
   if(sz(cur)<4){ 
   	 for(int xd=0;xd<4-sz(cur);xd++) s.pb('0');
   }
   for(char x:cur) s.pb(x);
   if(!is_palindrome(s)) return 0;
   return 1;
}


void solve(){
  
  array<int,3> dp[32][13][9195];
  
  array<int,3> last={-1,-1,-1};
  for(int y=9194;y>=1;y--){
  	for(int m=12;m>=1;m--){
  		for(int d=31;d>=1;d--){
  		   if(!check(d,m,y)) continue;
           if(last[0]==-1) dp[d][m][y]=last;
           else if(valid(last[0],last[1],last[2])) dp[d][m][y]=last;
           else dp[d][m][y]=dp[last[0]][last[1]][last[2]];
           last={d,m,y};
  		}
  	}
  }

  int q;
  cin >> q;
  
  while(q--){
  	string s;
  	cin >> s;
  	int d = (s[0]-'0')*10 + s[1]-'0';
  	int m = (s[3]-'0')*10 + s[4]-'0';
  	int y = (s[6]-'0')*1000 + (s[7]-'0')*100 + (s[8]-'0')*10 + s[9]-'0';
  	cout << dp[d][m][y][0] << '.' << dp[d][m][y][1] << '.' << dp[d][m][y][2] << '.' << endl;	
  }
}

int32_t main(){

  cin.tie(0); ios::sync_with_stdio(0);
  
  int t=1;//cin >> t;
  while(t--) solve();

  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 749 ms 90248 KB Output isn't correct
2 Incorrect 813 ms 90248 KB Output isn't correct
3 Incorrect 830 ms 90252 KB Output isn't correct
4 Incorrect 816 ms 90252 KB Output isn't correct
5 Incorrect 813 ms 90248 KB Output isn't correct
6 Incorrect 877 ms 90252 KB Output isn't correct
7 Incorrect 760 ms 90260 KB Output isn't correct
8 Incorrect 799 ms 90252 KB Output isn't correct
9 Incorrect 817 ms 90196 KB Output isn't correct
10 Incorrect 781 ms 90248 KB Output isn't correct