Submission #238613

#TimeUsernameProblemLanguageResultExecution timeMemory
238613SamAndDatum (COCI20_datum)C++17
50 / 50
793 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); int q[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; struct ban { int y, m, d; ban(){} ban(int y, int m, int d) { this->y = y; this->m = m; this->d = d; } }; bool operator<(const ban& a, const ban& b) { if (a.y < b.y) return true; if (a.y > b.y) return false; if (a.m < b.m) return true; if (a.m > b.m) return false; return a.d < b.d; } vector<ban> u; void pre() { for (int y = 0; y <= 9999; ++y) { if (y % 4 == 0) q[1] = 29; for (int m = 1; m <= 12; ++m) { for (int d = 1; d <= q[m - 1]; ++d) { vector<int> v; int x = y; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 4) v.push_back(0); x = m; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 6) v.push_back(0); x = d; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 8) v.push_back(0); reverse(all(v)); bool z = true; for (int i = 0; i < 8; ++i) { if (v[i] != v[8 - i - 1]) { z = false; break; } } if (z) { u.push_back(ban(y, m, d)); } } } q[1] = 28; } } void solv() { int qq; scanf("%d", &qq); while (qq--) { char a[20]; scanf(" %s", a); int y = 0, d = 0, m = 0; for (int i = 6; i < 6 + 4; ++i) { y = y * 10 + a[i] - '0'; } for (int i = 3; i < 3 + 2; ++i) { m = m * 10 + a[i] - '0'; } for (int i = 0; i < 0 + 2; ++i) { d = d * 10 + a[i] - '0'; } ban ans = *upper_bound(all(u), ban(y, m, d)); y = ans.y; d = ans.d; m = ans.m; vector<int> v; int x = y; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 4) v.push_back(0); x = m; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 6) v.push_back(0); x = d; while (x) { v.push_back(x % 10); x /= 10; } while (v.size() < 8) v.push_back(0); reverse(all(v)); printf("%d%d.%d%d.%d%d%d%d.\n", v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); } } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING //ios_base::sync_with_stdio(false), cin.tie(0); pre(); solv(); return 0; } //while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}

Compilation message (stderr)

datum.cpp: In function 'void solv()':
datum.cpp:97:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &qq);
     ~~~~~^~~~~~~~~~~
datum.cpp:101:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", a);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...