Submission #845705

# Submission time Handle Problem Language Result Execution time Memory
845705 2023-09-06T15:00:12 Z vjudge1 Datum (COCI20_datum) C++11
0 / 50
1000 ms 672 KB
#include <bits/stdc++.h>
#define lg(a) (31 - __builtin_clz((a)))
// #define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define st first
#define nd second
#define all(aa) aa.begin(), aa.end()
#define rall(aa) aa.rbegin(), aa.rend()
#define forn(i, n) for(int i=0;i<n;i++)
#define trav(e, x) for(auto& e:x)
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n))   //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
using namespace std;
/*

*/

vector<string> pal;


// void precalc(){
// 	int s[8];
// 	int ispal=0;
// 	while (!ispal){
// 		d++; 
// 		if(d>=28){
// 			if(m==1 or m==3 or m==5 or m==7 or m==8 or m==10 or m==12){
// 				d = (d-1)%31 + 1;
// 				m += d/31;
// 				m = (m-1)%12 +1;
// 				y +=m/12; 
// 			}
// 			if(m==4 or m==6 or m==9 or m==11){
// 				d = (d-1)%30 + 1;
// 				m += d/30;
// 				m = (m-1)%12 +1;
// 				y +=m/12;
// 			}
// 			if(m==2 and y%4!=0){
// 				d = (d-1)%28 + 1;
// 				m += d/28;
// 				m = (m-1)%12 +1;
// 				y +=m/12;
// 			}
// 			else{
// 				if(m==2 and y%4==0){
// 				d = (d-1)%29 + 1;
// 				m += d/29;
// 				m = (m-1)%12 +1;
// 				y +=m/12;
// 				}
// 			}
// 		}
// 		s[0] = d/10;
// 		s[1] = d%10;
// 		s[2] = m/10;
// 		s[3] = m%10;
// 		s[4] = y/1000 ;
// 		s[5] = (y/100)%10 ;
// 		s[6] = (y/10) % 10 ;
// 		s[7] = y%10;
// 		// cout<<s[0]<<s[1]<<'.'<<s[x2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<endl;
// 		if(s[0]==s[7] and s[1] == s[6] and s[2]==s[5] and s[3]==s[4]){
// 			ispal=1;
// 		}
// 	}
// }


void solve(){
	string a; cin>>a;
	int d=(a[0]-'0')*10 + (a[1]-'0'), m = (a[3]-'0')*10 + (a[4]-'0'), y=1000*(a[6]-'0') + 100*(a[7]-'0')+10*(a[8]-'0')+(a[9]-'0');
	int s[8];
	int ispal=0;
	while (!ispal){
		d++; 
		if(d>=28){
			if(m==1 or m==3 or m==5 or m==7 or m==8 or m==10 or m==12){
				d = (d-1)%31 + 1;
				m += d/31;
				m = (m-1)%12 +1;
				y +=m/12; 
			}
			else if(m==4 or m==6 or m==9 or m==11){
				d = (d-1)%30 + 1;
				m += d/30;
				m = (m-1)%12 +1;
				y +=m/12;
			}
			else if(m==2 and y%4!=0){
				d = (d-1)%28 + 1;
				m += d/28;
				m = (m-1)%12 +1;
				y +=m/12;
			}
			else{
				if(m==2 and y%4==0){
				d = (d-1)%29 + 1;
				m += d/29;
				m = (m-1)%12 +1;
				y +=m/12;
				}
			}
		s[2] = m/10;
		s[3] = m%10;
		s[4] = y/1000 ;
		s[5] = (y/100)%10 ;
		s[6] = (y/10) % 10 ;
		s[7] = y%10;
		}
		s[0] = d/10;
		s[1] = d%10;
		// cout<<s[0]<<s[1]<<'.'<<s[x2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<endl;
		if(s[0]==s[7] and s[1] == s[6] and s[2]==s[5] and s[3]==s[4]){
			ispal=1;
		}
	}
	cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;

}

int main(){
	// precalc();
	int test; 
    cin >> test;
   	while (test--){
		solve();
    }
}



Compilation message

datum.cpp: In function 'void solve()':
datum.cpp:124:66: warning: 's[7]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                                                                  ^~~
datum.cpp:124:57: warning: 's[6]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                                                         ^
datum.cpp:124:51: warning: 's[5]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                                                   ^
datum.cpp:124:37: warning: 's[3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                                     ^~~
datum.cpp:124:45: warning: 's[4]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                                             ^
datum.cpp:124:28: warning: 's[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  124 |  cout<<s[0]<<s[1]<<'.'<<s[2]<<s[3]<<'.'<<s[4]<<s[5]<<s[6]<<s[7]<<'.'<<endl;
      |                            ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Execution timed out 1033 ms 672 KB Time limit exceeded
3 Incorrect 1 ms 344 KB Output isn't correct
4 Incorrect 2 ms 344 KB Output isn't correct
5 Incorrect 3 ms 504 KB Output isn't correct
6 Incorrect 3 ms 344 KB Output isn't correct
7 Incorrect 4 ms 344 KB Output isn't correct
8 Incorrect 4 ms 344 KB Output isn't correct
9 Incorrect 4 ms 344 KB Output isn't correct
10 Execution timed out 1048 ms 600 KB Time limit exceeded