# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845723 |
2023-09-06T15:05:58 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
1000 ms |
720 KB |
#include <bits/stdc++.h>
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define pc __builtin_popcountll
#define vp vector<pii>
#define sp << " " <<
#define all(x) x.bg()+1,x.end()
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 2e5+1;
string printyear(int year) {
string ss = to_string(year);
while (ss.size() < 4) {
ss = "0"+ss;
}
string ans;
ans+=ss[3];
ans+=ss[2];
ans+='.';
ans+=ss[1];
ans+=ss[0];
ans+='.';
ans+=ss;
ans+='.';
return ans;
}
void solve() {
int q;
cin >> q;
vector<int> goodyears;
vi cap(13);
cap = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31};
for (int y=0;y<=9999;y++) {
string s = to_string(y);
while (s.size() < 4) s = "0"+s;
string month;
month+=s[1];
month+=s[0];
if (stoi(month) > 12 || !stoi(month)) continue;
string day;
day+=s[3];
day+=s[2];
if (y%4 == 0) cap[2]++;
int m = stoi(month);
int d = stoi(day);
if (d>cap[m] || !stoi(day)) {
if (y%4 == 0) cap[2]--;
continue;
}
if (y%4 == 0) cap[2]--;
goodyears.pb(y);
//cout << printyear(y) << endl;
}
while (q--) {
string s;
cin >> s;
string year;
year+=s[6];
year+=s[7];
year+=s[8];
year+=s[9];
int y = stoi(year);
int x = *lower_bound(goodyears.bg(),goodyears.end(),y);
int x2 = *upper_bound(goodyears.bg(),goodyears.end(),y);
string p = printyear(x);
int thismonth = 10*(s[3]-'0')+(s[4]-'0');
int thisday = 10*(s[0]-'0')+(s[1]-'0');
int thatyear = 1000*(p[6]-'0')+100*(p[7]-'0')+10*(p[8]-'0')+(p[9]-'0');
int thatmonth = 10*(p[3]-'0')+(p[4]-'0');
int thatday = 10*(p[0]-'0')+(p[1]-'0');
if (thatyear > y) {
cout << p << endl;
return;
}
if (thatmonth > thismonth) {
cout << p << endl;
return;
}
if (thatday > thisday) {
cout << p << endl;
return;
}
cout << printyear(x2) << endl;
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
#endif
int t = 1;
cin >> t;
while (t --> 0) solve();
}
Compilation message
datum.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize "DostSeferoğlu"
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
2 |
Execution timed out |
1090 ms |
720 KB |
Time limit exceeded |
3 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
464 KB |
Output isn't correct |
6 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
604 KB |
Output isn't correct |
10 |
Execution timed out |
1072 ms |
440 KB |
Time limit exceeded |