# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709947 | pcc | Datum (COCI20_datum) | C++14 | 531 ms | 436 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<tuple<int,int,int>> v;
int cnt = 0;
bool check(int y,int m,int d){
string sy = to_string(y);
sy = string(4-sy.size(),'0')+to_string(y);
string sm = (m/10?"":"0")+to_string(m);
string sd = (d/10?"":"0")+to_string(d);
sy = sd+sm+sy;
for(int i = 0;i<sy.size()/2;i++)if(sy[i] != sy[sy.size()-1-i])return false;
return true;
}
void add(int year){
int month = 1,day = 1;
bool leap = false;
if(year%400 == 0)leap = true;
else if(year%100 == 0)leap = false;
else if(year%4 == 0)leap = true;
else leap = false;
while(month!=13){
if(check(year,month,day))v.push_back(make_tuple(year,month,day));
day++;
if(month == 2){
if(leap&&day == 29){
day = 1;
month++;
}
else if(!leap&&day == 28){
day = 1;
month++;
}
}
else if(month == 1||month == 3||month == 5||month==7||month==8||month == 10||month == 12){
if(day == 31){
day = 1;
month++;
}
}
else{
if(day == 30){
day = 1;
month++;
}
}
}
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
auto c = clock();
for(int i = 0;i<1e4;i++){
add(i);
}
int t;
cin>>t;
assert(t<=10);
while(t--){
string s;
cin>>s;
tuple<int,int,int> tmp = make_tuple(stoi(s.substr(6,4)),stoi(s.substr(3,2)),stoi(s.substr(0,2)));
auto k = *upper_bound(v.begin(),v.end(),tmp);
int y = get<0>(k),m = get<1>(k),d = get<2>(k);
string sy = to_string(y);
sy = string(4-sy.size(),'0')+to_string(y);
string sm = (m/10?"":"0")+to_string(m);
string sd = (d/10?"":"0")+to_string(d);
cout<<sd<<'.'<<sm<<'.'<<sy<<'.'<<'\n';
}
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |