text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
string s;
int cnt[2016][13][32], Max, ansY, ansM, ansD;
int main() {
getline(cin, s);
Max = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] >= '0' && s[i] <= '9') {
int d = s[i] - '0';
if (s[i + 1] >= '0' && s[i + 1] <= '9') {
d = d * 10 + (s[i + 1] - '0');
if (d == 0 || d > 31) continue;
if (s[i + 2] == '-') {
if (s[i + 3] >= '0' && s[i + 3] <= '9') {
int m = s[i + 3] - '0';
if (s[i + 4] >= '0' && s[i + 4] <= '9') {
m = m * 10 + (s[i + 4] - '0');
if (m == 0 || m > 12) continue;
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 ||
m == 12) {
if (d > 31) continue;
} else if (m == 2) {
if (d > 28) continue;
} else {
if (d > 30) continue;
}
if (s[i + 5] == '-') {
if (s[i + 6] == '2') {
if (s[i + 7] == '0') {
if (s[i + 8] == '1') {
if (s[i + 9] >= '3' && s[i + 9] <= '5') {
int y = 2010 + (s[i + 9] - '0');
cnt[y][m][d]++;
if (cnt[y][m][d] > Max) {
Max = cnt[y][m][d];
ansY = y;
ansM = m;
ansD = d;
}
}
}
}
}
}
}
}
}
}
}
}
if (ansD >= 10) {
printf("%d", ansD);
} else {
printf("0%d", ansD);
}
printf("-");
if (ansM >= 10) {
printf("%d", ansM);
} else {
printf("0%d", ansM);
}
printf("-");
printf("%d\n", ansY);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int d[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int t, n;
string s;
map<int, int> red;
void output(int idx, int a[]) {
for (int i = 0; i <= idx; i++) cout << a[i] << endl;
}
void work() {
red.clear();
int idx = 0;
string res[maxn], a = "";
for (int i = 0; i < s.length(); i++) {
if (s[i] == '-') {
res[idx++] = a;
a = "";
} else {
a.push_back(s[i]);
}
}
res[idx] = a;
for (int i = idx; i >= 2; i--) {
if (res[i].length() >= 4) {
int tmp = (res[i][0] - '0') * 1000 + (res[i][1] - '0') * 100 +
(res[i][2] - '0') * 10 + (res[i][3] - '0');
if (tmp >= 2013 && tmp <= 2015) {
int dd = tmp * 10000;
if (res[i - 1].length() == 2) {
tmp = (res[i - 1][0] - '0') * 10 + (res[i - 1][1] - '0');
if (tmp > 0 && tmp <= 12) {
dd += tmp * 100;
if (res[i - 2].length() >= 2) {
int mm = tmp;
tmp = (res[i - 2][res[i - 2].length() - 2] - '0') * 10 +
(res[i - 2][res[i - 2].length() - 1] - '0');
if (tmp > 0 && tmp <= d[mm]) {
dd += tmp;
red[dd]++;
}
}
}
}
}
}
}
int amt = 0, ans;
for (map<int, int>::iterator it = red.begin(); it != red.end(); it++) {
if (it->second >= amt) {
amt = it->second;
ans = it->first;
}
}
for (int i = 0; i < 2; i++) {
if (ans % 100 < 10)
cout << "0" << ans % 100 << "-";
else
cout << ans % 100 << "-";
ans /= 100;
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
while (cin >> s) work();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int check(string s) {
if (s[2] != '-' || s[5] != '-') return 0;
for (int i = 0; i < 10; i++)
if (i != 2 && i != 5)
if (s[i] == '-') return 0;
int mm = stoi(s.substr(3, 2));
int dd = stoi(s.substr(0, 2));
int yyyy = stoi(s.substr(6, 4));
if (yyyy < 2013 || yyyy > 2015) return 0;
if (mm == 0 || mm > 12) return 0;
if (dd == 0 || dd > month[mm - 1]) return 0;
return 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
int n = s.size();
map<string, int> mapper;
string best;
for (int i = 0; i + 9 < n; i++) {
string curr = s.substr(i, 10);
if (check(curr)) mapper[curr]++;
if (mapper[curr] > mapper[best]) best = curr;
}
cout << best << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int ans[2050][15][50];
int data[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool judge(int d, int m, int y) {
if (y <= 2015 && y >= 2013) {
if (m >= 1 && m <= 12) {
if (d >= 1 && d <= data[m - 1]) return true;
}
}
return false;
}
const int N = 1e5 + 100;
char st[N];
int getnex(int x, int n, int &len) {
int now = 0;
len = 0;
for (int i = x; i < n; i++) {
if (st[i] == '-') break;
now *= 10;
now += st[i] - '0';
len++;
if (len == 4) return now;
}
return now;
}
vector<int> G;
int main() {
scanf("%s", st);
int len = strlen(st);
for (int i = 0; i < len; i++) {
if (st[i] == '-') G.push_back(i);
}
for (int i = 0; i < len; i++) {
if (st[i] == '-') continue;
int l;
int d = getnex(i, len, l);
if (l != 2) d = 100;
int now = upper_bound(G.begin(), G.end(), i) - G.begin();
if (now == G.size()) continue;
int m = getnex(G[now] + 1, len, l);
if (l != 2) m = 100;
now = upper_bound(G.begin(), G.end(), G[now]) - G.begin();
if (now == G.size()) continue;
int y = getnex(G[now] + 1, len, l);
if (l != 4) y = 0;
if (judge(d, m, y)) {
ans[y][m][d]++;
}
}
int mx = 0;
int dd = 0, mm = 0, yy = 0;
for (int i = 2013; i <= 2015; i++) {
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= 31; k++) {
if (ans[i][j][k] > mx) {
mx = ans[i][j][k];
yy = i, mm = j, dd = k;
}
}
}
}
printf("%02d-%02d-%d\n", dd, mm, yy);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[100010];
int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int anum;
map<string, int> ms;
bool isnum(char a) { return a >= '0' && a <= '9'; }
int main() {
while (~scanf("%s", s)) {
ms.clear();
anum = 0;
int tmp = 0;
string tt;
int max = 0;
for (int i = 0; s[i + 9] != 0; i++) {
if (isnum(s[i]) && isnum(s[i + 1]) && !isnum(s[i + 2]) &&
isnum(s[i + 3]) && isnum(s[i + 4]) && !isnum(s[i + 5]) &&
isnum(s[i + 6]) && isnum(s[i + 7]) && isnum(s[i + 8]) &&
isnum(s[i + 9])) {
int a0 = atoi(s + i), a1 = atoi(s + i + 3), a2;
char ttt = s[i + 10];
s[i + 10] = 0;
a2 = atoi(s + i + 6);
s[i + 10] = ttt;
if (a2 <= 2015 && a2 >= 2013 && a1 <= 12 && a1 >= 1 && a0 > 0 &&
a0 <= mon[a1]) {
ms[string(s + i, s + i + 10)]++;
if (ms[string(s + i, s + i + 10)] > max) {
tt = string(s + i, s + i + 10);
max = ms[tt];
}
}
}
}
printf("%s", tt.c_str());
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int d[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans[1000010];
int a[40000000], b[1000000];
int main() {
string str;
int ma = 0, tot = 0, t = 0, an = 0;
cin.tie(0);
cin >> str;
for (int i = 2; i < str.length() - 6; ++i)
if (str[i] == '-' && str[i + 3] == '-' && str[i - 1] != '-' &&
str[i + 1] != '-' && str[i + 7] != '-' && str[i + 2] != '-' &&
str[i - 2] != '-') {
tot++;
for (int j = i - 2; j <= i + 7; ++j) ans[tot] += str[j];
}
for (int i = 1; i <= tot; ++i) {
int sum1, sum2, sum3;
sum1 = (ans[i][0] - '0') * 10 + (ans[i][1] - '0');
sum2 = (ans[i][3] - '0') * 10 + (ans[i][4] - '0');
sum3 = (ans[i][6] - '0') * 1000 + (ans[i][7] - '0') * 100 +
(ans[i][8] - '0') * 10 + (ans[i][9] - '0');
if (sum1 > d[sum2]) continue;
if (sum3 < 2013 || sum3 > 2015) continue;
if (sum1 <= 0) continue;
a[sum3 * 10000 + sum2 * 100 + sum1]++;
b[++t] = sum3 * 10000 + sum2 * 100 + sum1;
}
for (int i = 1; i <= t; ++i) {
if (a[b[i]] > ma) ma = a[b[i]], an = b[i];
}
if (an % 100 < 10)
cout << 0 << an % 100 << '-';
else
cout << an % 100 << '-';
if (an / 100 % 100 < 10)
cout << 0 << an / 100 % 100 << '-';
else
cout << an / 100 % 100 << '-';
cout << an / 10000;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
const int day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n = 0, y, m, d, j;
string str, v, x;
int main() {
cin >> str;
for (int i = 0; i + 10 <= str.length(); i++) {
x = str.substr(i, 10);
if (sscanf((x + "#1").c_str(), "%2d-%2d-%4d#%d", &d, &m, &y, &j) != 4)
continue;
if (j != 1 || y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 ||
d > day[m])
continue;
mp[x]++;
if (n < mp[x]) n = mp[x], v = x;
}
cout << v << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int days[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool validity(string s) {
for (int i = 0; i < 10; i++) {
if (i == 2 || i == 5) {
if (s[i] == '-')
continue;
else
return false;
}
if (s[i] >= '0' && s[i] <= '9')
continue;
else
return false;
}
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');
if (y < 2013 || y > 2015) return false;
if (m < 1 || m > 12) return false;
if (d < 1 || d > days[m]) return false;
return true;
}
int main() {
map<string, int> m;
map<string, int>::iterator it;
int max = 0;
string s, tmp, proph;
cin >> s;
int len = s.length();
for (int i = 0; i + 10 <= len; i++) {
tmp = s.substr(i, 10);
bool f = validity(tmp);
if (f) {
it = m.find(tmp);
if (it == m.end()) {
m.insert(make_pair(tmp, 1));
if (max == 0) {
max = 1;
proph = tmp;
}
} else {
int f = it->second;
f++;
if (f > max) {
max = f;
proph = tmp;
}
m.erase(it);
m.insert(make_pair(tmp, f));
}
}
}
cout << proph << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int to_int(string s) {
stringstream ss;
if (s.find('-') != -1) return 0;
ss << s;
int r = 0;
ss >> r;
return r;
}
bool check(string s) {
if (s.length() != 10 || s[2] != '-' || s[5] != '-') return false;
int d = to_int(s.substr(0, 2));
int m = to_int(s.substr(3, 2));
int y = to_int(s.substr(6, 4));
if (y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 || d > days[m - 1])
return false;
return true;
}
int main() {
ios_base::sync_with_stdio(false);
string s;
cin >> s;
map<string, int> m;
for (int i = 0; i < s.size() - 9; i++) {
string sub = s.substr(i, 10);
if (!check(sub)) continue;
if (m.count(sub))
m.find(sub)->second++;
else
m.insert(pair<string, int>(sub, 1));
}
pair<string, int> ans = *m.begin();
for (map<string, int>::iterator it = m.begin(); it != m.end(); it++)
if (it->second > ans.second) ans = *it;
cout << ans.first << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int checkyear(char ch1, char ch2, char ch3, char ch4) {
if (ch1 == '2' && ch2 == '0' && ch3 == '1' &&
(ch4 == '3' || ch4 == '4' || ch4 == '5'))
return 1;
else
return 0;
}
long long int checkmonth(char ch1, char ch2) {
if (ch1 == '0' && ch2 == '2')
return 1;
else if (ch1 == '0' &&
(ch2 == '1' || ch2 == '3' || ch2 == '5' || ch2 == '7' || ch2 == '8'))
return 3;
else if ((ch1 == '1') && (ch2 == '0' || ch2 == '2'))
return 3;
else if ((ch1 == '0') && (ch2 == '4' || ch2 == '6' || ch2 == '9'))
return 2;
else if (ch1 == '1' && ch2 == '1')
return 2;
else
return 0;
}
long long int checkday(char ch1, char ch2, long long int month) {
if (month == 1) {
if ((ch1 == '0') &&
(ch2 == '1' || ch2 == '2' || ch2 == '3' || ch2 == '4' || ch2 == '5' ||
ch2 == '6' || ch2 == '7' || ch2 == '8' || ch2 == '9'))
return 1;
else if ((ch1 == '1') &&
(ch2 == '0' || ch2 == '1' || ch2 == '2' || ch2 == '3' ||
ch2 == '4' || ch2 == '5' || ch2 == '6' || ch2 == '7' ||
ch2 == '8' || ch2 == '9'))
return 1;
else if ((ch1 == '2') && (ch2 == '0' || ch2 == '1' || ch2 == '2' ||
ch2 == '3' || ch2 == '4' || ch2 == '5' ||
ch2 == '6' || ch2 == '7' || ch2 == '8'))
return 1;
else
return 0;
} else if (month == 2) {
if ((ch1 == '0') &&
(ch2 == '1' || ch2 == '2' || ch2 == '3' || ch2 == '4' || ch2 == '5' ||
ch2 == '6' || ch2 == '7' || ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '1') &&
(ch2 == '0' || ch2 == '1' || ch2 == '2' || ch2 == '3' ||
ch2 == '4' || ch2 == '5' || ch2 == '6' || ch2 == '7' ||
ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '2') &&
(ch2 == '0' || ch2 == '1' || ch2 == '2' || ch2 == '3' ||
ch2 == '4' || ch2 == '5' || ch2 == '6' || ch2 == '7' ||
ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '3') && (ch2 == '0')) {
return 1;
} else
return 0;
} else if (month == 3) {
if ((ch1 == '0') &&
(ch2 == '1' || ch2 == '2' || ch2 == '3' || ch2 == '4' || ch2 == '5' ||
ch2 == '6' || ch2 == '7' || ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '1') &&
(ch2 == '0' || ch2 == '1' || ch2 == '2' || ch2 == '3' ||
ch2 == '4' || ch2 == '5' || ch2 == '6' || ch2 == '7' ||
ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '2') &&
(ch2 == '0' || ch2 == '1' || ch2 == '2' || ch2 == '3' ||
ch2 == '4' || ch2 == '5' || ch2 == '6' || ch2 == '7' ||
ch2 == '8' || ch2 == '9')) {
return 1;
} else if ((ch1 == '3') && (ch2 == '0' || ch2 == '1')) {
return 1;
} else
return 0;
}
}
int main() {
char a[100003], b[1000];
string s;
scanf("%s", a);
map<string, long long int> m;
map<string, long long int>::iterator it, pos;
long long int len, i = 0, c, d, j = 0, year, month, day;
len = strlen(a);
for (i = 0; i <= (len - 10); i++) {
j = 0;
year = checkyear(a[i + 6], a[i + 7], a[i + 8], a[i + 9]);
if (year) {
month = checkmonth(a[i + 3], a[i + 4]);
if (month) {
day = checkday(a[i], a[i + 1], month);
if (day && a[i + 2] == '-' && a[i + 5] == '-') {
b[0] = a[i];
b[1] = a[i + 1];
b[2] = a[i + 2];
b[3] = a[i + 3];
b[4] = a[i + 4];
b[5] = a[i + 5];
b[6] = a[i + 6];
b[7] = a[i + 7];
b[8] = a[i + 8];
b[9] = a[i + 9];
b[10] = '\0';
s = b;
m[s]++;
}
}
}
}
long long int max = 0;
it = m.begin();
for (; it != m.end(); it++) {
if ((it->second) > max) {
max = it->second;
pos = it;
}
}
cout << pos->first;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
const int day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n = 0, y, m, d, j;
string str, v, x;
int main() {
cin >> str;
for (int i = 0; i + 10 <= str.length(); i++) {
x = str.substr(i, 10);
if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 || d > day[m])
continue;
mp[x]++;
if (n < mp[x]) n = mp[x], v = x;
}
cout << v << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) { return int(c - '0'); }
bool goodDate(string s) {
if (s[9] < '3' || s[9] > '5' || s[8] != '1' || s[7] != '0' || s[6] != '2' ||
s[9] == '-')
return false;
if (s[5] != '-') return false;
if (s[3] > '1' || s[3] == '-') return false;
if (s[3] == '1') {
if (s[4] > '2' || s[4] == '-') return false;
} else {
if (s[4] == '0' || s[4] == '-') return false;
}
if (s[2] != '-') return false;
int men = ctoi(s[3]) * 10 + ctoi(s[4]);
if (s[0] == '-' || s[1] == '-') return false;
int dien = ctoi(s[0]) * 10 + ctoi(s[1]);
if (dien == 0) return false;
if (men == 1 || men == 3 || men == 5 || men == 7 || men == 8 || men == 10 ||
men == 12) {
if (dien > 31) return false;
} else if (men == 4 || men == 6 || men == 9 || men == 11) {
if (dien > 30) return false;
} else {
if (dien > 28) return false;
}
return true;
}
map<string, int> dq;
int main() {
string s;
cin >> s;
for (int i = 0; i < s.size() - 9; i++) {
string date = s.substr(i, 10);
if (goodDate(date)) {
dq[date]++;
}
}
map<string, int>::iterator it;
int best = 0;
string bestDate = "";
for (it = dq.begin(); it != dq.end(); it++) {
if ((*it).second > best) {
best = (*it).second;
bestDate = (*it).first;
}
}
cout << bestDate << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int to_n(string &s, long long c, int n) {
int ans = 0;
int i;
for (i = 0; i < n; i++) {
ans = ans * 10 + s[c + i] - '0';
}
return ans;
}
bool is_dig(char a) {
if ('0' <= a && a <= '9') {
return true;
} else {
return false;
}
}
int main() {
long long i, j, k;
string s;
cin >> s;
int d[3][13][32];
for (i = 0; i < 3; i++) {
for (j = 0; j < 13; j++) {
for (k = 0; k < 32; k++) {
d[i][j][k] = 0;
}
}
}
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long c = -1;
int yr, mnth, dt;
while (1) {
c = s.find("201", c + 1);
if ((c == string::npos) || (c + 3 >= s.length())) {
break;
} else if (!('3' <= s[c + 3] && s[c + 3] <= '5')) {
continue;
} else if (c < 6) {
continue;
} else if (s[c - 1] != '-' || s[c - 4] != '-') {
continue;
} else if (!is_dig(s[c - 2]) || !is_dig(s[c - 3]) || !is_dig(s[c - 5]) ||
!is_dig(s[c - 6])) {
continue;
}
yr = to_n(s, c, 4);
mnth = to_n(s, c - 3, 2);
dt = to_n(s, c - 6, 2);
if (dt > m[mnth]) {
continue;
}
d[yr - 2013][mnth][dt]++;
}
long long max_i = 0, max_j = 0, max_k = 0, max_v = d[0][0][0];
for (i = 0; i < 3; i++) {
for (j = 1; j < 13; j++) {
for (k = 1; k < 32; k++) {
if (max_v < d[i][j][k]) {
max_i = i;
max_j = j;
max_k = k;
max_v = d[i][j][k];
}
}
}
}
if (max_k < 10) {
cout << "0" << max_k << "-";
} else {
cout << max_k << "-";
}
if (max_j < 10) {
cout << "0" << max_j << "-";
} else {
cout << max_j << "-";
}
cout << max_i + 2013;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string kip[100005];
int rec[100005], a[100005];
char s[100005];
map<string, int> mm;
string cur;
int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool chk(int id) {
int flag, i, d1, m1, y1;
flag = true;
cur.clear();
for (i = id; i < id + 10; i++) {
if (i == (id + 2) || i == (id + 5)) {
if (s[i] != '-') flag = false;
} else {
if (s[i] > '9' || s[i] < '0') flag = false;
}
a[i] = s[i] - '0';
cur = cur + s[i];
}
char b = 0;
cur = cur + b;
if (flag == false) return false;
d1 = a[id] * 10 + a[id + 1];
m1 = a[id + 3] * 10 + a[id + 4];
y1 = a[id + 6] * 1000 + a[id + 7] * 100 + a[id + 8] * 10 + a[id + 9];
flag = false;
if (2012 < y1 && y1 < 2016) {
if (0 < m1 && m1 < 13) {
if (0 < d1 && d1 <= mon[m1]) {
flag = true;
}
}
}
return flag;
}
int main() {
int k, mxnow, cnt, i;
scanf("%s", s);
k = strlen(s);
mm.clear();
mxnow = -1;
cnt = 1;
for (i = 0; i < k - 9; i++) {
if (chk(i) == false) continue;
if (mm.find(cur) == mm.end()) {
mm[cur] = cnt;
rec[cnt] = 0;
kip[cnt] = cur;
cnt++;
}
int now;
now = mm[cur];
rec[now]++;
mxnow = max(rec[now], mxnow);
}
for (i = 1; i < cnt; i++) {
if (rec[i] == mxnow) {
printf("%s\n", kip[i].c_str());
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int ans[33][33][2222], n, k;
string t, res;
int dig(char c) { return (int)(c - '0'); }
void check() {
if (t[2] != '-' || t[5] != '-') return;
int cnt = 0;
for (int i = 0; i < 10; i++)
if (t[i] == '-') cnt++;
if (cnt > 2) return;
int d = dig(t[0]) * 10 + dig(t[1]);
int m = dig(t[3]) * 10 + dig(t[4]);
int y = dig(t[6]) * 1000 + dig(t[7]) * 100 + dig(t[8]) * 10 + dig(t[9]);
if (m < 1 || m > 12) return;
if (d < 1 || d > month[m]) return;
if (y < 2013 || y > 2015) return;
ans[d][m][y]++;
if (ans[d][m][y] > k) {
k = ans[d][m][y];
res = t;
}
}
int main() {
string s;
cin >> s;
n = s.size();
for (int i = 0; i < n; i++) {
t = "00-00-0000";
for (int j = i, at = 0; j < i + 10 && j < n; j++, at++) t[at] = s[j];
check();
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int ok[] = {0, 1, 3, 4, 6, 7, 8, 9};
int len;
map<string, int> m;
char in[100001];
void solve(int p) {
if (p + 10 > len) return;
string aux;
for (int i = 0; i < 10; ++i) aux += in[i + p];
bool k = 1;
for (int i = 0; i < 8 && k; ++i) k = aux[ok[i]] <= '9' && aux[ok[i]] >= '0';
k &= aux[2] == '-' && aux[5] == '-';
if (k) {
int day, month, year;
sscanf(aux.c_str(), "%d-%d-%d", &day, &month, &year);
if (month > 0 && month <= 12 && day > 0 && day <= days[month] &&
year >= 2013 && year <= 2015)
m[aux]++;
}
solve(p + 1);
}
int main() {
scanf("%s", in);
len = strlen(in);
solve(0);
vector<pair<int, string> > vet;
for (typeof(m.begin()) it = m.begin(); it != m.end(); ++it)
vet.push_back(make_pair(it->second, it->first));
sort(vet.begin(), vet.end());
printf("%s\n", vet[vet.size() - 1].second.c_str());
}
|
#include <bits/stdc++.h>
using namespace std;
const int MIN = 2013, MAX = 2015;
const int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dist[13] = {0};
struct Date {
int year, month, day;
Date() { year = month = day = 0; }
Date(int n) {
n++;
year = month = day = 0;
while (n > 365) {
n -= 365;
year++;
}
for (int i = 0; i < 13; i++)
if (n > dist[i]) month = i + 1;
day = n - dist[month - 1];
}
int toInt() { return dist[month - 1] + day + 365 * year; }
friend ostream &operator<<(ostream &output, const Date &date) {
return output << setw(2) << setfill('0') << date.day << "-" << setw(2)
<< setfill('0') << date.month << "-" << MIN + date.year;
}
bool isValid() const {
return 0 <= year && year < 3 && 1 <= month && month < 13 && 1 <= day &&
day <= months[month];
}
};
string input;
int freq[3 * 365 + 1] = {0};
inline int strToInt(const string &str) {
stringstream ss(str);
int res;
ss >> res;
return res;
}
void parse(const string &str) {
Date date;
string strs[3];
strs[0] = str.substr(0, 2), strs[1] = str.substr(3, 2),
strs[2] = str.substr(6, 4);
bool ok = true;
for (int i = 0; i < 3; i++)
for (int j = 0; j < (int)strs[i].size(); j++)
if (!isdigit(strs[i][j])) ok = false;
if (!ok || str[2] != '-' || str[5] != '-') return;
date.day = strToInt(strs[0]);
date.month = strToInt(strs[1]);
date.year = strToInt(strs[2]) - MIN;
if (date.isValid()) freq[date.toInt()]++;
}
int main() {
for (int i = 1; i < 13; i++) dist[i] = dist[i - 1] + months[i];
cin >> input;
const int LEN = 10;
for (int i = 0; i + LEN <= (int)input.size(); i++)
parse(input.substr(i, LEN));
int ans = 0, mFreq = 0;
for (int i = 0; i < 3 * 365 + 1; i++)
if (freq[i] > mFreq) {
mFreq = freq[i];
ans = i;
}
cout << Date(ans - 1) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, string> mp;
map<string, int> mpp;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int j = 0;
for (int j = 0; j < s.size(); j++) {
string findd = "";
findd += s[j];
if (j <= s.size() - 4) {
findd += s[j + 1];
findd += s[j + 2];
findd += s[j + 3];
}
if (findd == "2013") {
string tmp = "";
for (int i = j + 3; i >= 0 && i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 30) ||
(a > 0 && tmp1 == "11" && a <= 30) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 31) ||
(a > 0 && tmp1 == "10" && a <= 31) ||
(a > 0 && tmp1 == "12" && a <= 31))) {
mpp[tmp]++;
}
} else if (findd == "2014") {
string tmp = "";
for (int i = j + 3; i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 31) ||
(a > 0 && tmp1 == "11" && a <= 31) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 30) ||
(a > 0 && tmp1 == "10" && a <= 30) ||
(a > 0 && tmp1 == "12" && a <= 30))) {
mpp[tmp]++;
}
} else if (findd == "2015") {
string tmp = "";
for (int i = j + 3; i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 31) ||
(a > 0 && tmp1 == "11" && a <= 31) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 30) ||
(a > 0 && tmp1 == "10" && a <= 30) ||
(a > 0 && tmp1 == "12" && a <= 30))) {
mpp[tmp]++;
}
}
}
int mx = 0;
for (map<string, int>::iterator it = mpp.begin(); it != mpp.end(); it++) {
mx = max((*it).second, mx);
}
for (map<string, int>::iterator it = mpp.begin(); it != mpp.end(); it++) {
if ((*it).second == mx) {
cout << (*it).first << endl;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> date;
int month_len[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
for (int y = 2013; y <= 2015; y++) {
for (int m = 1; m <= 12; m++) {
for (int d = 1; d <= month_len[m]; d++) {
stringstream ss;
ss << setfill('0') << setw(2) << d << '-';
ss << setfill('0') << setw(2) << m << '-' << y;
date[ss.str()] = 0;
}
}
}
string s;
cin >> s;
for (int i = 0; i <= s.length() - 10; i++)
if (date.count(s.substr(i, 10))) date[s.substr(i, 10)]++;
string ans;
int max_cnt = -1;
for (map<string, int>::iterator it = date.begin(); it != date.end(); it++)
if (it->second > max_cnt) {
ans = it->first;
max_cnt = it->second;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int d, m, y, k, mx, mxi;
int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool f;
int dd[5000], mm[5000], yy[5000], s[5000];
int pm(char x) {
if (((x - 48) >= 0) && ((x - 48) <= 9)) {
return x - 48;
} else {
return -1;
}
}
int main() {
string a;
cin >> a;
for (int i = 0; i < a.length(); i++) {
if ((pm(a[i]) != -1) && (pm(a[i + 1]) != -1) && (a[i + 2] == '-') &&
(pm(a[i + 3]) != -1) && (pm(a[i + 4]) != -1) && (a[i + 5] == '-') &&
(pm(a[i + 6]) != -1) && (pm(a[i + 7]) != -1) && (pm(a[i + 8]) != -1) &&
(pm(a[i + 9]) != -1) && (pm(a[i + 3]) * 10 + pm(a[i + 4]) <= 12) &&
((pm(a[i]) * 10 + pm(a[i + 1]) <=
day[pm(a[i + 3]) * 10 + pm(a[i + 4])]))) {
d = pm(a[i]) * 10 + pm(a[i + 1]);
m = pm(a[i + 3]) * 10 + pm(a[i + 4]);
y = pm(a[i + 6]) * 1000 + pm(a[i + 7]) * 100 + pm(a[i + 8]) * 10 +
pm(a[i + 9]);
if ((d == 0) || (m == 0)) continue;
if ((y < 2013) || (y > 2015)) continue;
f = true;
for (int j = 0; j < k; j++) {
if ((dd[j] == d) && (mm[j] == m) && (yy[j] == y)) {
f = false;
s[j]++;
}
}
if (f) {
dd[k] = d;
mm[k] = m;
yy[k] = y;
s[k] = 1;
k++;
}
}
}
for (int i = 0; i < k; i++) {
if (s[i] > mx) {
mx = s[i];
mxi = i;
}
}
if (dd[mxi] / 10 == 0) {
cout << 0 << dd[mxi] << "-";
} else {
cout << dd[mxi] << "-";
}
if (mm[mxi] / 10 == 0) {
cout << 0 << mm[mxi] << "-";
} else {
cout << mm[mxi] << "-";
}
cout << yy[mxi];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int main() {
int T[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s, t, Ans = "", M;
int d = 0, m = 0, y = 0, x = 0;
cin >> s;
for (int i = 0; i <= s.length() - 10; i++) {
t = s.substr(i + 6, 4);
if (t != "2013" && t != "2014" && t != "2015") continue;
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
if (s[i + 3] == '-' || s[i + 4] == '-') continue;
if (s[i] == '-' || s[i + 1] == '-') continue;
m = 10 * int(s[i + 3] - '0') + int(s[i + 4] - '0');
d = 10 * int(s[i] - '0') + int(s[i + 1] - '0');
if (m > 12 || d > T[m] || d == 0) continue;
M = s.substr(i, 10);
mp[M]++;
if (mp[M] > x) Ans = M, x = mp[M];
}
cout << Ans;
}
|
#include <bits/stdc++.h>
using namespace std;
bool correct(int day, int month) {
if (day == 0 || month == 0) return false;
if (month == 2 && day <= 28)
return true;
else if ((month == 4 || month == 6 || month == 9 || month == 11) && day <= 30)
return true;
else if (day <= 31 && (month == 1 || month == 3 || month == 5 || month == 7 ||
month == 8 || month == 10 || month == 12))
return true;
return false;
}
int main() {
stringstream ss;
vector<string> v;
map<string, int> mp;
string s, t, month, day, res;
cin >> s;
int x, y;
for (int i = s.size() - 1; i >= 9; i--) {
t.push_back(s[i - 3]);
t.push_back(s[i - 2]);
t.push_back(s[i - 1]);
t.push_back(s[i]);
if (t == "2013" || t == "2015" || t == "2014") {
if (s[i - 4] == '-' && s[i - 7] == '-' && isdigit(s[i - 6]) &&
isdigit(s[i - 5]) && isdigit(s[i - 9]) && isdigit(s[i - 8])) {
month.push_back(s[i - 6]);
month.push_back(s[i - 5]);
day.push_back(s[i - 9]);
day.push_back(s[i - 8]);
ss << month;
ss >> x;
ss.clear();
ss << day;
ss >> y;
ss.clear();
if (correct(y, x)) {
res = day + "-" + month + "-" + t;
v.push_back(res);
mp[res]++;
}
month = "";
day = "";
}
}
t = "";
}
res = v[0];
for (int i = 1; i < v.size(); i++) {
if (mp[v[i]] > mp[res]) res = v[i];
}
cout << res;
}
|
#include <bits/stdc++.h>
int YEAR[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int A[32][13][3];
int main(void) {
char S[100005] = "";
char* str;
int l, max = 0, md, mm, my;
memset(A, 0, 32 * 13 * 3 * sizeof(int));
scanf("%s", S);
l = strlen(S);
str = S;
while (str < S + l) {
int m, d, y;
while (str[0] < '0' && str[1] < '1' && str + 1 < S + l) str++;
if (str[2] != '-' && str + 2 < S + l) {
str++;
continue;
}
if (str[3] < '0' || str[4] < '0' || str + 4 >= S + l) {
str += 4;
continue;
}
m = (str[3] - '0') * 10 + (str[4] - '0');
if (m == 0 || m > 12) {
str += 3;
continue;
}
d = (str[0] - '0') * 10 + (str[1] - '0');
if (d == 0 || d > YEAR[m]) {
str += 3;
continue;
}
if (str[5] != '-') {
str += 4;
continue;
}
if (str[6] < '0' || str[7] < '0' || str[8] < '0' || str[9] < '0' ||
str + 9 >= S + l) {
str += 3;
continue;
}
y = (str[6] - '0') * 1000 + (str[7] - '0') * 100 + (str[8] - '0') * 10 +
(str[9] - '0');
if (y < 2013 || y > 2015) {
str += 8;
continue;
}
A[d][m][y - 2013]++;
str += 8;
}
for (int i = 0; i < 32; i++) {
for (int j = 0; j < 13; j++) {
for (int k = 0; k < 3; k++) {
int a = A[i][j][k];
if (a > max) {
max = a;
md = i;
mm = j;
my = 2013 + k;
}
}
}
}
printf("%02d-%02d-%d\n", md, mm, my);
return 0;
}
|
#include <bits/stdc++.h>
const int mod = ((1E9) + 7);
const int intmax = ((1E9) + 7);
using namespace std;
string s[1120];
int lps[15];
int count_[1120];
void cal_lcp(string &p) {
int j = -1;
int i = 0;
lps[0] = -1;
while (i < p.size()) {
while (j >= 0 && p[i] != p[j]) j = lps[j];
i++;
j++;
lps[i] = j;
}
}
void kmp(string &t, string &p, int x) {
int i = 0, j = 0;
while (i < t.size()) {
while (j >= 0 && t[i] != p[j]) j = lps[j];
i++;
j++;
if (j == p.size()) count_[x]++;
}
}
string to_string_(int a) {
stringstream ss;
ss << a;
string t;
ss >> t;
return t;
}
int main() {
ios::sync_with_stdio(0);
int test, a, b, c;
int n, m;
int max_ = 0, pos = -1;
string text;
cin >> text;
int x = 0;
for (int i = 1; i <= 31; i++)
for (int j = 1; j <= 12; j++)
for (int k = 2013; k <= 2015; k++) {
if (j == 2 && i > 28) break;
if (j <= 7 && j % 2 == 0 && i == 31) break;
if (j > 7 && j % 2 != 0 && i == 31) break;
if (i < 10) s[x] += '0';
s[x] += to_string_(i);
s[x] += '-';
if (j < 10) s[x] += '0';
s[x] += to_string_(j);
s[x] += '-';
s[x] += to_string_(k);
x++;
}
for (int i = 0; i < x; i++) {
cal_lcp(s[i]);
kmp(text, s[i], i);
if (count_[i] > max_) {
pos = i;
max_ = count_[i];
}
}
cout << s[pos];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = -1e18;
const long long INF = 1e18;
long long d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s, ans;
map<string, int> us;
long long mx;
int main() {
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i + 9 < s.size()) {
if (s[i + 2] == s[i + 5] && s[i + 5] == '-') {
if (isdigit(s[i]) && isdigit(s[i + 1]) && isdigit(s[i + 3]) &&
isdigit(s[i + 4]) && isdigit(s[i + 6]) && isdigit(s[i + 7]) &&
isdigit(s[i + 8]) && isdigit(s[i + 9])) {
int day = (s[i] - '0') * 10 + (s[i + 1] - '0');
int mounth = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
int year = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
(s[i + 8] - '0') * 10 + (s[i + 9] - '0');
if (year >= 2013 && year <= 2015) {
if (mounth >= 1 && mounth <= 12) {
if (day >= 1 && day <= d[mounth]) {
string str = "";
for (int j = i; j <= i + 9; j++) {
str += s[j];
}
us[str]++;
if (us[str] > mx) {
mx = us[str];
ans = str;
}
}
}
}
}
}
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10,
mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, m, x, y, z, a[3][13][32], mx, ans;
char s[N];
inline bool check(int y, int m, int d) {
if (y < 2013 || y > 2015) return 0;
if (m <= 0 || m > 12) return 0;
if (d <= 0 || d > mon[m]) return 0;
return 1;
}
int main() {
scanf("%s", s);
for (int i = 0; s[i + 9]; ++i)
if (s[i] != '-' && s[i + 1] != '-' && s[i + 2] == '-' && s[i + 3] != '-' &&
s[i + 4] != '-' && s[i + 5] == '-' && s[i + 6] != '-' &&
s[i + 7] != '-' && s[i + 8] != '-' && s[i + 9] != '-') {
x = (s[i] - 48) * 10 + s[i + 1] - 48;
y = (s[i + 3] - 48) * 10 + s[i + 4] - 48;
z = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 +
(s[i + 8] - 48) * 10 + s[i + 9] - 48;
if (check(z, y, x))
if (++a[z - 2013][y][x] > mx) mx = a[z - 2013][y][x], ans = i;
}
for (int i = ans; i <= ans + 9; ++i) putchar(s[i]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
int r = 0;
istringstream sin(s);
sin >> r;
return r;
}
long long toInt64(string s) {
long long r = 0;
istringstream sin(s);
sin >> r;
return r;
}
double toDouble(string s) {
double r = 0;
istringstream sin(s);
sin >> r;
return r;
}
string toString(long long n) {
string s, s1;
while (n / 10 > 0) {
s += (char)((n % 10) + 48);
n /= 10;
}
s += (char)((n % 10) + 48);
n /= 10;
s1 = s;
for (long long i = 0; i < s.length(); i++) s1[(s.length() - 1) - i] = s[i];
return s1;
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) { return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; }
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
long long Max[50][50][10], maxx = 0;
int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long A, B, C;
string s, s1;
void chemidunam() {
if (s[0] == '-') return;
if (s[1] == '-') return;
if (s[2] != '-') return;
if (s[3] == '-') return;
if (s[4] == '-') return;
if (s[5] != '-') return;
if (s[6] != '2') return;
if (s[7] != '0') return;
if (s[8] != '1') return;
if (s[9] != '3' && s[9] != '4' && s[9] != '5') return;
int jday = (int)(s[0] - '0') * 10 + (s[1] - '0');
int jmonth = (int)(s[3] - '0') * 10 + (s[4] - '0');
if (jmonth < 1 || jmonth > 12) return;
if (jday < 1 || jday > months[jmonth - 1]) return;
int jyear = s[9] - '0';
Max[jday][jmonth][jyear]++;
if (Max[jday][jmonth][jyear] > maxx) {
A = jday;
B = jmonth;
C = jyear;
maxx = Max[jday][jmonth][jyear];
};
}
int main() {
cin >> s1;
s = "dd-mm-yyyy";
for (int i = 0; i + s.length() <= s1.size(); i++) {
for (int j = 0; j < s.length(); j++) s[j] = s1[i + j];
chemidunam();
}
if (A < 10) cout << "0";
cout << A;
cout << "-";
if (B < 10) cout << "0";
cout << B;
cout << "-";
cout << "201" << C << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int to_int(string s) {
int x = 0;
for (int i = 0; i < (int)s.size(); ++i) x *= 10, x += s[i] - '0';
return x;
}
char s[100005];
map<string, int> mp;
string tmp, mx;
int d, mn, y, mxx = -1, n,
m[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(int argc, char **argv) {
scanf("%s", s);
n = strlen(s);
for (int i = 0; i < n - 9; ++i) {
if (isdigit(s[i]) && isdigit(s[i + 1]) && s[i + 2] == '-' &&
isdigit(s[i + 3]) && isdigit(s[i + 4]) && s[i + 5] == '-' &&
isdigit(s[i + 6]) && isdigit(s[i + 7]) && isdigit(s[i + 8]) &&
isdigit(s[i + 9])) {
tmp = "";
for (int j = i; j < i + 10; ++j) tmp += s[j];
d = (s[i] - '0') * 10 + (s[i + 1] - '0');
mn = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
y = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
(s[i + 8] - '0') * 10 + (s[i + 9] - '0');
if (y >= 2013 && y <= 2015 && mn >= 1 && mn <= 12 && d <= m[mn] &&
d >= 1) {
++mp[tmp];
if (mp[tmp] > mxx) {
mxx = mp[tmp];
mx = tmp;
}
}
}
}
printf("%s", mx.c_str());
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int getDaysInMonth(int month) {
month--;
if (month == 1) return 28;
return 31 - (month % 7) % 2;
}
bool check(string &value, int start) {
int day = 0, month = 0, year = 0;
for (int i = 0; i < 10; i++) {
if ((i == 2) || (i == 5)) {
if (value[start + i] != '-') return false;
} else if (value[start + i] == '-')
return false;
}
year = (value[start + 6] - '0') * 1000 + (value[start + 7] - '0') * 100 +
(value[start + 8] - '0') * 10 + (value[start + 9] - '0');
if (!((year >= 2013) && (year <= 2015))) return false;
month = (value[start + 3] - '0') * 10 + (value[start + 4] - '0');
if (!((month >= 1) && (month <= 12))) return false;
day = (value[start] - '0') * 10 + (value[start + 1] - '0');
if (!((day >= 1) && (day <= getDaysInMonth(month)))) return false;
return true;
}
int main() {
string in;
cin >> in;
int biggest = 0;
string anwser;
map<string, int> dict;
int len = in.size() - 9;
map<string, int>::iterator it;
for (int i = 0; i < len; i++) {
if (check(in, i)) {
string tmp(in, i, 10);
it = dict.find(tmp);
int count = 1;
if (it != dict.end()) {
count = ++(it->second);
} else {
dict.insert(make_pair(tmp, 1));
}
if (count > biggest) {
biggest = count;
anwser = tmp;
}
}
}
cout << anwser;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const bool digitPos[] = {1, 1, 0, 1, 1, 0, 1, 1, 1, 1};
const int digitPosNum = 10;
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[MAXN];
inline bool isDigit(char ch) { return ch >= '0' && ch <= '9'; }
inline int getNum(const char *str, int n) {
int res = 0;
for (int i = 0; i < n; ++i) {
res = res * 10 + str[i] - '0';
}
return res;
}
inline void printZero(int x) {
if (x < 10) {
printf("0");
}
printf("%d", x);
}
struct Date {
int year, month, day;
int time;
bool tryParse(const char *date) {
for (int i = 0; i < digitPosNum; ++i) {
if (digitPos[i]) {
if (!isDigit(date[i])) {
return false;
}
} else {
if (date[i] != '-') {
return false;
}
}
}
day = getNum(date, 2);
month = getNum(date + 3, 2);
year = getNum(date + 6, 4);
if (year < 2013 || year > 2015) {
return false;
}
if (month < 1 || month > 12) {
return false;
}
if (day < 1 || day > days[month]) {
return false;
}
time = year * 10000 + month * 100 + day;
return true;
}
bool operator<(const Date &date) const { return time < date.time; }
void output() {
printZero(day);
printf("-");
printZero(month);
printf("-%d\n", year);
}
};
map<Date, int> dateNum;
int main() {
while (~scanf("%s", s)) {
Date date;
dateNum.clear();
for (int i = 0; s[i]; ++i) {
if (date.tryParse(s + i)) {
++dateNum[date];
}
}
int ans = 0;
for (map<Date, int>::iterator it = dateNum.begin(); it != dateNum.end();
++it) {
if (it->second > ans) {
ans = it->second;
date = it->first;
}
}
date.output();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[50][50][50];
int main() {
string s;
cin >> s;
int arr[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int d = 0, m = 0, y = 0, mx = 0, ans1 = 0, ans2 = 0, ans3 = 0;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
bool c = false;
for (int j = 0; j < 9; j++)
if (j != 5 && j != 2 && s[i + j] == '-') c = true;
if (c) continue;
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
d = (s[i] - 48) * 10 + (s[i + 1] - 48);
m = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
y = s[i + 9] - 48;
if (y < 3 || y > 5) continue;
if (m < 1 || m > 12) continue;
if (d < 1 || d > arr[m]) continue;
a[y][m][d]++;
if (a[y][m][d] > mx) {
mx = a[y][m][d];
ans1 = d;
ans2 = m;
ans3 = y;
}
}
cout << ans1 / 10 << ans1 % 10 << "-" << ans2 / 10 << ans2 % 10 << "-201"
<< ans3 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int mes[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> M;
void Valid(string s) {
int ct = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] == '-') s[i] = ' ', ct++;
if (ct != 2) return;
if (s[2] != ' ' || s[5] != ' ') return;
istringstream in(s);
int d, m, a;
in >> d >> m >> a;
if (m <= 0 || m > 12) return;
if (a < 2013 || a > 2015) return;
if (d <= 0 || d > mes[m - 1]) return;
s[2] = s[5] = '-';
M[s]++;
}
int main() {
string s;
while (cin >> s) {
for (int i = 0; i < s.size(); i++)
if (i + 9 < s.size()) Valid(s.substr(i, 10));
int maxi = 0;
string ans = "";
map<string, int>::iterator it;
for (it = M.begin(); it != M.end(); ++it) {
if (maxi < it->second) maxi = it->second, ans = it->first;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int dp[35][15][5];
int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[100005];
int main() {
int d, m, y;
int ad, am, ay, mx = 0;
scanf("%s", s);
int len = strlen(s);
for (int i = 0; i + 9 < len; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
bool flag = true;
for (int j = 0; j <= 9; j++) {
if (j == 2 || j == 5) continue;
if (s[i + j] < '0' || s[i + j] > '9') {
flag = false;
break;
}
}
if (flag == false) continue;
d = (s[i] - '0') * 10 + s[i + 1] - '0';
m = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
if (m < 1 || m > 12 || d < 1 || d > month[m]) continue;
y = s[i + 9] - '0';
if (y < 3 || y > 5) continue;
dp[d][m][y]++;
if (dp[d][m][y] > mx) {
mx = dp[d][m][y];
ad = d, am = m, ay = y;
}
}
printf("%02d-%02d-201%d\n", ad, am, ay);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int toNum(string s) {
int ans = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] >= '0' && s[i] <= '9') {
ans = ans * 10 + (s[i] - '0');
} else
return -1;
return ans;
}
bool check(string s) {
if (s[2] != '-' || s[5] != '-') return 0;
string ngay = s.substr(0, 2);
int Ngay = toNum(ngay);
if (Ngay < 1 || Ngay > 31) return 0;
string thang = s.substr(3, 2);
int Thang = toNum(thang);
if (Thang < 1 || Thang > 12) return 0;
string nam = s.substr(6, 4);
int Nam = toNum(nam);
if (Nam < 2013 || Nam > 2015) return 0;
if (Thang == 4 || Thang == 6 || Thang == 9 || Thang == 11)
if (Ngay > 30) return 0;
if (Thang == 2 && Ngay > 28) return 0;
return 1;
}
string s;
map<string, int> m;
map<string, int>::iterator it;
int main() {
cin >> s;
for (int i = 0; i < s.size() - 9; i++)
if (s[i] != '-') {
string tmp = s.substr(i, 10);
if (check(tmp)) m[tmp]++;
}
string ans = "1";
m[ans] = 0;
for (it = m.begin(); it != m.end(); it++) {
if (it->second > m[ans]) ans = it->first;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long get() {
char c = getchar();
long long x = 0LL;
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
x *= 10LL;
x += (c - '0');
c = getchar();
}
return x;
}
string s;
int dm[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
int main() {
ios::sync_with_stdio(0);
cin >> s;
for (int i = 0; i < s.size() - 9; i++) {
string t = s.substr(i, 10);
string d = t.substr(0, 2), m = t.substr(3, 2), y = t.substr(6, 4);
if (t[2] != '-' || t[5] != '-') continue;
bool f = true;
for (int j = 0; j < 2; j++)
if (!isdigit(d[j]) || !isdigit(m[j])) f = false;
for (int j = 0; j < 4; j++)
if (!isdigit(y[j])) f = false;
if (!f) continue;
int dd, mm, yy;
dd = mm = yy = 0;
for (int j = 0; j < 2; j++) {
dd = dd * 10 + (d[j] - '0');
mm = mm * 10 + (m[j] - '0');
}
for (int j = 0; j < 4; j++) yy = yy * 10 + (y[j] - '0');
if (dd < 1 || dd > dm[mm]) continue;
if (mm < 1 || mm > 12) continue;
if (yy < 2013 || yy > 2015) continue;
mp[t]++;
}
int mx = 0;
for (__typeof(mp.begin()) it = (mp.begin()); it != (mp).end(); it++) {
if (it->second > mx) mx = it->second;
}
for (__typeof(mp.begin()) it = (mp.begin()); it != (mp).end(); it++) {
if (it->second == mx) {
cout << it->first;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, max1, dd, mm, yy;
string s;
int store[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int cache[50][2050][20];
bool check(int k) {
for (int i = 0; i < 9; i++) {
if (i == 2 || i == 5) {
if (s[k + i] != '-') return false;
} else {
if (!(s[k + i] >= '0' && s[k + i] <= '9')) return false;
}
}
return true;
}
int calc(int k) { return (s[k] - '0') * 10 + (s[k + 1] - '0'); }
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cin >> s;
n = s.size();
for (int i = 0; i < n - 9; i++) {
if (check(i)) {
int date = calc(i);
int month = calc(i + 3);
int year = calc(i + 6) * 100 + calc(i + 8);
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 &&
date >= 1 && date <= store[month]) {
cache[date][month][year]++;
if (cache[date][month][year] > max1) {
max1 = cache[date][month][year];
dd = date;
mm = month;
yy = year;
}
}
}
}
printf("%02d-%02d-%04d", dd, mm, yy);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> cnt;
const int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void check(string s) {
if (count(s.begin(), s.end(), '-') != 2) {
return;
}
string ddS, mmS, yyS;
string cur = "";
for (char x : s) {
if (x == '-') {
if (ddS == "") {
ddS = cur;
} else if (mmS == "") {
mmS = cur;
} else if (yyS == "") {
yyS = cur;
}
cur = "";
} else {
cur += x;
}
}
yyS = cur;
if (ddS == "" or mmS == "" or yyS == "") return;
if (yyS[0] == '0') return;
int dd = stoi(ddS);
int mm = stoi(mmS);
int yy = stoi(yyS);
if (yy >= 2013 and yy <= 2015) {
if (mm >= 1 and mm <= 12) {
if (dd > 0) {
if (dd <= day[mm]) {
if (ddS.size() == 1) {
ddS = "0" + ddS;
}
if (mmS.size() == 1) {
mmS = "0" + mmS;
}
string built = ddS + "-" + mmS + "-" + yyS;
cnt[built]++;
}
}
}
}
}
signed main() {
ios::sync_with_stdio(0);
cin.sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
for (int add = 9; add <= 9; add++) {
for (int i = 0; i + add < s.size(); i++) {
string a;
for (int j = 0; j <= add; j++) {
a += s[i + j];
}
check(a);
}
}
int ma = 0;
string mas = "?";
for (auto x : cnt) {
if (x.second >= ma) {
ma = x.second;
mas = x.first;
}
}
cout << mas << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
string a;
int h1[100][100][10];
int moth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool panduan[10] = {0, 0, 1, 0, 0, 1};
bool pan(string m) {
string h(m, 6, 4);
if (h != "2013" && h != "2014" && h != "2015") return 0;
int u = (m[0] - '0') * 10 + m[1] - '0', v = (m[3] - '0') * 10 + m[4] - '0',
z = m[9] - '0';
if ((0 < v && v <= 12 && u > 0 && u <= moth[v]) == 0) return 0;
for (int i = 0; i < 10; i++)
if (panduan[i] != (m[i] == '-')) return 0;
h1[u][v][z]++;
return 1;
}
string huanyuan(int i, int j, int o) {
string u = "";
u += char(i / 10 + int('0'));
u += char(i % 10 + int('0'));
u += '-';
u += char(j / 10 + int('0'));
u += char(j % 10 + int('0'));
u += '-';
u += "201";
u += char(o + int('0'));
return u;
}
int main(int argc, char *argv[]) {
cin >> a;
for (int i = 0; i <= a.size() - 10; i++) {
string m(a, i, 10);
pan(m);
}
string e;
int u = 0;
for (int i = 0; i < 40; i++) {
for (int j = 0; j < 20; j++) {
for (int o = 0; o < 10; o++) {
if (h1[i][j][o] > u) {
u = h1[i][j][o];
e = huanyuan(i, j, o);
}
}
}
}
cout << e << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int cnt[100000];
int calc(string str) {
if (str[2] != '-' || str[5] != '-') return 50000;
if (str[6] != '2') return 50000;
if (str[7] != '0') return 50000;
if (str[8] != '1') return 50000;
if (str[9] < '3' || str[9] > '5') return -1;
for (int i = 0; i < 5; i++)
if (str[i] == '-' && i != 2) return 50000;
int d = (str[0] - '0') * 10 + str[1] - '0';
int m = (str[3] - '0') * 10 + str[4] - '0';
if (m < 1 || m > 12) return 50000;
if (d < 1 || d > day[m - 1]) return 50000;
return (str[9] - '3') * 10000 + m * 100 + d;
}
int main() {
string str;
cin >> str;
for (int i = 0; i + 9 < str.length(); i++) cnt[calc(str.substr(i, 10))]++;
int idx = -1, mx = 0;
for (int i = 0; i < 30000; i++)
if (mx < cnt[i]) idx = i, mx = cnt[i];
printf("%02d-%02d-%d\n", idx % 100, (idx / 100) % 100, 2013 + idx / 10000);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int read() {
int x;
scanf("%d", &x);
return x;
}
long long readL() {
long long x;
scanf("%I64d", &x);
return x;
}
bool isdigits(string s) {
int sl = s.length();
for (int i = 0; i < sl; i++) {
if (!isdigit(s[i])) return false;
}
return true;
}
int sstoi(string s) {
istringstream buffer(s);
int value;
buffer >> value;
return value;
}
bool ispattern(string s) {
int sl = s.length();
if (sl != 10) return false;
if (s[2] != '-' || s[5] != '-') return false;
int f = s.find('-');
if (f < 2 || f > 5 || (f > 2 && f < 5)) return false;
if (!isdigits(s.substr(0, 2)) || !isdigits(s.substr(3, 2)) ||
!isdigits(s.substr(6, 4)))
return false;
int dd = sstoi(s.substr(0, 2));
if (dd < 1 || dd > 31) return false;
int mm = sstoi(s.substr(3, 2));
if (mm < 1 || mm > 12 || (mm == 2 && dd > 28) ||
((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30))
return false;
int yyyy = sstoi(s.substr(6, 4));
if (yyyy < 2013 || yyyy > 2015) return false;
return true;
}
string res;
map<string, int> m;
int main() {
string s;
cin >> s;
int sl = s.length();
if (sl < 10) return cout << -1, 0;
for (int i = 0; i <= sl - 9; i++) {
if (ispattern(s.substr(i, 10))) m[s.substr(i, 10)]++;
}
int mx = -1e9;
for (auto e : m) {
if (e.second > mx) {
mx = e.second;
res = e.first;
}
}
if (mx == -1e9) return cout << -1, 0;
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int num[100005];
map<int, string> ans;
map<string, int> mp;
int mouth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int k = 1;
void judge(int i) {
char ss[20];
int l = 0;
if (s[i + 2] != '-' || s[i + 5] != '-') return;
for (int j = i; j < i + 10; j++) {
ss[l++] = s[j];
if (j == i + 2 || j == i + 5) continue;
if (!(s[j] >= '0' && s[j] <= '9')) return;
}
ss[l] = '\0';
int dd = (s[i] - '0') * 10 + s[i + 1] - '0';
int mm = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
int yy = 0;
for (int j = i + 6; j < i + 10; j++) {
yy = yy * 10 + s[j] - '0';
}
if (!(yy >= 2013 && yy <= 2015)) return;
if (!(mm >= 1 && mm <= 12)) return;
if (!(dd >= 1 && dd <= mouth[mm])) return;
if (!mp[ss]) {
ans[k] = ss;
mp[ss] = k++;
}
num[mp[ss]]++;
}
int main() {
cin >> s;
int len = strlen(s);
for (int i = 0; i <= len - 10; i++) {
judge(i);
}
int index, max_ = -1;
for (int i = 1; i < k; i++) {
if (num[i] > max_) {
max_ = num[i];
index = i;
}
}
cout << ans[index];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
cout << x << endl;
exit(0);
}
const int maxn = 1e6 + 5;
const string S = "dd-mm-yyyy";
int M[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool valid(string s) {
if (s.length() != S.length()) return false;
if (s[2] != '-') return false;
if (s[5] != '-') return false;
for (int i = 0; i < int(s.length()); i++) {
if (i == 2) continue;
if (i == 5) continue;
if (!(s[i] >= '0' && s[i] <= '9')) return false;
}
int dd = stoi(s.substr(0, 2));
int mm = stoi(s.substr(3, 2));
int yy = stoi(s.substr(6));
return yy >= 2013 && yy <= 2015 && mm >= 1 && mm <= 12 && dd >= 1 &&
dd <= M[mm];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
map<string, int> mp;
string s;
cin >> s;
int n = s.length();
for (int i = 0; i + int(S.length()) <= n; i++) {
string tmp;
for (int j = 0; j < int(S.length()); j++) tmp += s[i + j];
if (valid(tmp)) mp[tmp]++;
}
string res = "*";
for (auto p : mp) {
if (res == "*" || p.second > mp[res]) res = p.first;
}
assert(res != "*");
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long G(long long a, long long b) {
if (b == 0) return a;
return G(b, a % b);
}
map<string, int> m;
map<string, bool> mark;
vector<string> v;
vector<pair<int, string> > q;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
ios_base::sync_with_stdio(false);
string s;
cin >> s;
for (int i = 0; i < s.length() - 9; i++) {
string ss = s.substr(i, 10);
if (!mark[ss]) v.push_back(ss);
mark[ss] = 1;
m[ss]++;
}
for (int i = 0; i < v.size(); i++) q.push_back(make_pair(m[v[i]], v[i]));
sort(q.begin(), q.end());
reverse(q.begin(), q.end());
for (int i = 0; i < q.size(); i++) {
string s = q[i].second;
if (s[2] != '-' || s[5] != '-') continue;
s[2] = s[5] = '0';
bool b = 0;
for (int j = 0; j < s.length(); j++)
if (s[j] == '-') b = 1;
if (b) continue;
s[2] = s[5] = '-';
int da, mo, ye;
da = 10 * s[0] + s[1] - 11 * '0';
mo = 10 * s[3] + s[4] - 11 * '0';
ye = 1000 * s[6] + 100 * s[7] + 10 * s[8] + s[9] - 1111 * '0';
if (ye < 2013 || ye > 2015) continue;
if (mo < 1 || mo > 12) continue;
if (da < 1 || da > day[mo]) continue;
cout << s << endl;
break;
}
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int days[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mx = -1;
string ans, neww;
int main() {
string a, b = "dd-mm-yyyy";
cin >> a;
int d, m, y, j;
for (int i = 0; i < a.length() - b.length() + 1; i++) {
neww = a.substr(i, b.length());
if (sscanf((neww + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (d >= 1 && d <= days[m] && m <= 12 && m >= 1 && y >= 2013 && y <= 2015) {
if (mx < ++mp[neww]) {
mx = mp[neww];
ans = neww;
}
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool valid(string s) {
int day = (s[0] - '0') * 10 + s[1] - '0';
int month = (s[3] - '0') * 10 + s[4] - '0';
int year =
(s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] - '0';
if (year > 2012 && year < 2016) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 ||
month == 10 || month == 12) {
if (day < 32 && day > 0) {
return true;
}
} else if (month == 2) {
if (day < 29 && day > 0) {
return true;
}
} else {
if (month < 13 && day < 31 && day > 0) {
return true;
}
}
}
return false;
}
int main() {
string s;
cin >> s;
vector<string> a;
for (int i = 0; s[i + 9] != '\0'; i++) {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i] != '-' && s[i + 1] != '-' &&
s[i + 3] != '-' && s[i + 4] != '-') {
string t = string(s.begin() + i, s.begin() + i + 10);
if (valid(t)) {
a.push_back(t);
}
}
}
int ma = 0, ind = -1;
sort(a.begin(), a.end());
for (int i = 0; i < a.size(); i++) {
int t = count(a.begin() + i, a.end(), a[i]);
if (t >= ma) {
ma = t;
ind = i;
}
i += t - 1;
}
cout << a[ind];
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
unordered_map<string, int> mp;
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(string s) {
if (s[2] != '-' || s[5] != '-') return false;
for (int i = 0; i < 10; ++i)
if (i != 2 && i != 5 && !isdigit(s[i])) return false;
int day, month, year;
char c;
stringstream ss(s);
ss >> day >> c >> month >> c >> year;
if (year < 2013 || year > 2015) return false;
if (month < 1 || month > 13) return false;
if (day < 1 || day > days[month]) return false;
return true;
}
int main() {
cin >> s;
for (int i = 0; i <= s.size() - 10; ++i) {
string t = s.substr(i, 10);
if (!check(t)) continue;
mp[t]++;
}
int mx = 0;
string ans;
for (auto &it : mp) {
if (it.second > mx) {
mx = it.second;
ans = it.first;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[100001];
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int validate(char* date) {
if (date[2] != '-' || date[5] != '-') return 0;
int dashes = 0;
for (int i = 0; i < 10; i++) dashes += date[i] == '-';
if (dashes != 2) return 0;
int day = (date[0] - '0') * 10 + date[1] - '0';
int month = (date[3] - '0') * 10 + date[4] - '0';
int year = (date[6] - '0') * 1000 + (date[7] - '0') * 100 +
(date[8] - '0') * 10 + (date[9] - '0');
if (year < 2013 || year > 2015) return 0;
if (month < 1 || month > 12) return 0;
if (day < 1 || day > days[month]) return 0;
return 1;
}
int main(void) {
cin >> s;
int len = strlen(s);
map<string, int> counter;
for (int i = 2, n = len - 7; i < n; i++) {
if (s[i] == '-') {
if (validate(s + i - 2)) {
string date(s + i - 2, 10);
counter[date]++;
}
}
}
map<string, int>::iterator ita, itb;
ita = counter.begin();
itb = counter.end();
string answ;
int maxi = 0;
for (; ita != itb; ita++) {
if (ita->second > maxi) {
maxi = ita->second;
answ = ita->first;
}
}
cout << answ << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const long long linf = 1000000000000000000LL;
typedef struct {
int dia, mes, ano;
} data;
vector<data> vetor;
string linha, str;
map<int, int> mapa;
int main() {
cin >> linha;
int s = linha.size();
data d;
for (int i = int(0); i <= int(s - 10); i++) {
str = linha.substr(i, 10);
if (isdigit(str[0]) && isdigit(str[1]) && !isdigit(str[2]) &&
isdigit(str[3]) && isdigit(str[4]) && !isdigit(str[5]) &&
isdigit(str[6]) && isdigit(str[7]) && isdigit(str[8]) &&
isdigit(str[9])) {
d.dia = (str[0] - '0') * 10 + str[1] - '0';
d.mes = (str[3] - '0') * 10 + str[4] - '0';
d.ano = (str[6] - '0') * 1000 + (str[7] - '0') * 100 +
(str[8] - '0') * 10 + str[9] - '0';
if (d.ano >= 2013 && d.ano <= 2015 && d.mes >= 1 && d.mes <= 12 &&
d.dia) {
if (d.mes == 2) {
if (d.dia <= 28) vetor.push_back(d);
} else if (d.mes <= 7) {
if (d.mes % 2) {
if (d.dia <= 31) vetor.push_back(d);
} else if (d.dia <= 30)
vetor.push_back(d);
} else {
if (d.mes % 2) {
if (d.dia <= 30) vetor.push_back(d);
} else if (d.dia <= 31)
vetor.push_back(d);
}
}
mapa[1000000 * d.dia + 10000 * d.mes + d.ano] = 0;
}
}
s = vetor.size();
int a, b, c;
for (int i = 0; i < s; i++) {
a = vetor[i].dia, b = vetor[i].mes, c = vetor[i].ano;
mapa[1000000 * a + 10000 * b + c]++;
}
int m = 0;
for (map<int, int>::iterator it = mapa.begin(); it != mapa.end(); it++)
if ((it->second) > m) m = it->second, a = it->first;
printf("%.2d-%.2d-%.4d\n", a / 1000000, a % 1000000 / 10000, a % 10000);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cnt[42][42][42];
char s[555555];
int every_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
scanf("%s", s);
int n = strlen(s);
int mx = 0, ad = 0, am = 0, ay = 0;
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i + 9 < n; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
int flag = 1;
for (int j = 0; j < 10; j++) {
if (j != 2 && j != 5 && s[i + j] == '-') flag = 0;
}
if (!flag) continue;
int dd = (s[i] - '0') * 10 + (s[i + 1] - '0');
int mm = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
int yy = s[i + 9] - '0';
if (yy < 3 || yy > 5) continue;
if (mm < 1 || mm > 12) continue;
if (dd < 1 || dd > every_month[mm]) continue;
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ad = dd, am = mm, ay = yy;
}
}
printf("%02d-%02d-%d", ad, am, ay + 2010);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
int num[2][13][105];
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void solve(string d) {
if (d[0] == '-' || d[1] == '-' || d[2] != '-' || d[3] == '-' || d[4] == '-' ||
d[5] != '-' || d[6] == '-' || d[7] == '-' || d[8] == '-' || d[9] == '-')
return;
int p = 0, y = 0, m = 0;
string t;
for (int i = 0; i < 2; i++) p = p * 10 + d[i] - '0';
for (int i = 3; i < 5; i++) m = m * 10 + d[i] - '0';
for (int i = 6; i < 10; i++) y = y * 10 + d[i] - '0';
if (y < 2013 || y > 2015) return;
if (m < 1 || m > 12) return;
if (p < 1 || p > month[m]) return;
num[y - 2013][m][p]++;
}
int y, m, d, mx;
void print() {
if (d < 10) cout << '0';
cout << d << '-';
if (m < 10) cout << '0';
cout << m;
cout << '-' << y;
}
int main() {
cin >> s;
for (int i = 0; i + 9 < s.size(); i++) solve(s.substr(i, 10));
for (int i = 0; i < 3; i++)
for (int j = 1; j <= 12; j++)
for (int k = 1; k <= month[j]; k++) {
if (num[i][j][k] > mx) {
y = i + 2013, m = j, d = k;
mx = num[i][j][k];
}
}
print();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> sum;
string ans;
int maks = -1;
int pola[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char in[100008];
int len;
bool valid(int a, int b) {
for (int i = a; i <= b; i++) {
if (i == a + 2 || i == a + 5) {
if (in[i] != '-') return 0;
} else {
if (in[i] == '-') return 0;
}
}
int day = ((in[a] - '0') * 10) + (in[a + 1] - '0');
int month = ((in[a + 3] - '0') * 10) + (in[a + 4] - '0');
int year = ((in[a + 6] - '0') * 1000) + ((in[a + 7] - '0') * 100) +
((in[a + 8] - '0') * 10) + (in[a + 9] - '0');
if (year < 2013 || year > 2015) return 0;
if (month < 1 || month > 13 || day < 1) return 0;
if (day > pola[month - 1]) return 0;
return 1;
}
void process() {
int a = 0, b = 9;
while (b < len) {
if (valid(a, b)) {
string tmp = "";
for (int i = a; i <= b; i++) {
tmp += in[i];
}
sum[tmp]++;
int n = sum[tmp];
if (n > maks) {
maks = n;
ans = tmp;
}
}
a++;
b++;
}
hell:
cout << ans << endl;
}
int main() {
scanf("%s", in);
len = strlen(in);
process();
}
|
#include <bits/stdc++.h>
using namespace std;
int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int pos[] = {0, 1, 3, 4, 6, 7, 8, 9};
map<string, int> m;
string parse(vector<char> v) {
string ans = "";
for (int i = 0; i < v.size(); i++) ans += v[i];
return ans;
}
void valid(vector<char> v) {
if (v.size() != 10) return;
for (int i = 0; i < 8; i++) {
if (v[pos[i]] < 48 || v[pos[i]] > 57) return;
}
if (v[2] != '-' || v[5] != '-') return;
int month = (v[3] - 48) * 10 + v[4] - 48;
int date = (v[0] - 48) * 10 + v[1] - 48;
int year = (v[6] - 48) * 1000 + (v[7] - 48) * 100 + (v[8] - 48) * 10 +
(v[9] - 48) * 1;
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 && date >= 1 &&
date <= d[month]) {
m[parse(v)]++;
}
}
void pop_front(vector<char> &v) {
if (!v.empty()) {
v.erase(v.begin());
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin >> s;
vector<char> v;
for (int i = 0; i < 10; i++) v.push_back(s[i]);
valid(v);
for (int i = 10; i < s.size(); i++) {
pop_front(v);
v.push_back(s[i]);
valid(v);
}
string ans = "";
int maxi = -1;
for (auto it : m) {
if (it.second > maxi) {
maxi = it.second;
ans = it.first;
}
}
cout << ans << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int MAX = 1000000;
int MIN = -1000000;
int INF = 1000000000;
int x4[4] = {0, 1, 0, -1};
int y4[4] = {1, 0, -1, 0};
int x8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int y8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int i, j, k;
int day[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool valid(string A) {
int i, garis = 0;
for (i = (0); i < (A.size()); i++)
if (A[i] == '-') garis++;
if (garis != 2) return false;
if (A[2] != '-' || A[5] != '-') return false;
int hari = ((A[0] - '0') * 10) + (A[1] - '0');
int bulan = ((A[3] - '0') * 10) + (A[4] - '0');
int tahun = ((A[6] - '0') * 1000) + ((A[7] - '0') * 100) +
((A[8] - '0') * 10) + (A[9] - '0');
if (bulan > 12 || bulan < 1) return false;
if (day[bulan] < hari || hari < 1) return false;
if (tahun < 2013 || tahun > 2015) return false;
return true;
}
int main() {
int i;
string kalimat, temp;
map<string, int> m;
vector<string> v;
cin >> kalimat;
for (i = 0; i <= kalimat.size() - 10; i++) {
temp.clear();
for (j = i; j < i + 10; j++) temp.push_back(kalimat[j]);
if (valid(temp) == true) {
if (m[temp] == 0) v.push_back(temp);
m[temp]++;
}
}
int maks = 0;
string ans;
for (i = (0); i < (v.size()); i++) {
int wew = m[v[i]];
if (wew > maks) {
ans = v[i];
maks = wew;
}
}
cout << ans << endl;
{
fflush(stdin);
getchar();
};
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
getline(cin >> ws, s);
vector<string> a;
string b = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] == '-') {
a.push_back(b);
b = "";
} else {
b += s[i];
}
}
a.push_back(b);
map<string, int> cnt;
int condition;
if (a.size() > 2) {
condition = a.size();
} else if (a.size() == 2) {
condition = 3;
}
for (int i = 2; i < condition; i++) {
if (a[i].size() >= 4) {
string year = "";
year += a[i][0];
year += a[i][1];
year += a[i][2];
year += a[i][3];
if (stoi(year) >= 2013 && stoi(year) <= 2015) {
if (a[i - 1].size() == 2) {
string month = "";
month = a[i - 1];
if (stoi(month) >= 1 && stoi(month) <= 12) {
if (a[i - 2].size() >= 2) {
string day = "";
day += a[i - 2][a[i - 2].size() - 2];
day += a[i - 2][a[i - 2].size() - 1];
if (stoi(month) <= 7) {
if (stoi(month) % 2) {
if (stoi(day) <= 31 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(month) == 2) {
if (stoi(day) <= 28 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(day) <= 30 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
}
}
} else {
if (stoi(month) % 2) {
if (stoi(day) <= 30 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(day) <= 31 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
}
}
}
}
}
}
}
}
int ans = 0;
string an;
for (auto it = cnt.begin(); it != cnt.end(); it++) {
if (it->second > ans) {
ans = it->second;
an = it->first;
}
}
cout << an << "\n";
}
|
#include <bits/stdc++.h>
char a[100000 + 2];
int vis[32][13][6];
int save[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void solve() {
memset(vis, 0, sizeof(vis));
int len = strlen(a);
int max = 0, d, m, y;
for (int i = 9; i < len; i++) {
if ((a[i] == '3' || a[i] == '4' || a[i] == '5') && a[i - 1] == '1' &&
a[i - 2] == '0' && a[i - 3] == '2') {
if (a[i - 4] != '-' || a[i - 7] != '-' || a[i - 5] == '-' ||
a[i - 6] == '-' || a[i - 8] == '-' || a[i - 9] == '-')
continue;
int dd = (a[i - 9] - '0') * 10 + (a[i - 8] - '0');
int mm = (a[i - 6] - '0') * 10 + (a[i - 5] - '0');
if (mm <= 12 && mm > 0 && dd > 0 && dd <= save[mm - 1]) {
int k = ++vis[dd][mm][a[i] - '0'];
if (k > max) {
max = k;
d = dd;
m = mm;
y = 2010 + a[i] - '0';
}
}
}
}
if (d < 10) printf("0");
printf("%d-", d);
if (m < 10) printf("0");
printf("%d-%d\n", m, y);
}
int main() {
while (gets(a)) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int toInt(char xx) { return xx - '0'; }
char toChar(int xx) { return xx + '0'; }
bool isDigit(char xx) { return ('0' <= xx && xx <= '9'); }
bool isCharacter(char xx) {
return (('a' <= xx && xx <= 'z') || ('A' <= xx && xx <= 'Z'));
}
void swapInt(int &x, int &y) {
x = x ^ y;
y = x ^ y;
x = x ^ y;
}
inline void clear_buffer() {
string tmp;
getline(cin, tmp);
}
struct Date {
int d, m, y;
Date() { d = m = y = 0; }
bool operator<(const Date &other) const {
if (y != other.y) return y < other.y;
if (d != other.d) return d < other.d;
if (m != other.m) return m < other.m;
return false;
}
void display() {
if (d >= 10) {
printf("%d-", d);
} else {
printf("0");
printf("%d-", d);
}
if (m >= 10) {
printf("%d-", m);
} else {
printf("0");
printf("%d-", m);
}
printf("%d\n", y);
}
};
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int Mod = 10;
const int maxn = (1e6) + 10;
bool exitInput = false;
const int days_in_month[15] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
const char gach = '-';
int dd, mm, yy;
map<Date, int> mp;
string s;
bool isCorrectFormat(int i) {
if (s[i + 2] != gach || s[i + 5] != gach) return false;
for (int j = 0; j < 9; ++j) {
if (j != 2 && j != 5 && s[i + j] == gach) return false;
}
return true;
}
bool isValidFormat(int i) {
int d, m, y;
d = toInt(s[i]) * 10 + toInt(s[i + 1]);
m = toInt(s[i + 3]) * 10 + toInt(s[i + 4]);
y = toInt(s[i + 6]) * 1000 + toInt(s[i + 7]) * 100 + toInt(s[i + 8]) * 10 +
toInt(s[i + 9]);
dd = d;
mm = m;
yy = y;
if (y < 2013 || y > 2015) {
return false;
}
if (m < 1 || m > 12) {
return false;
}
if (d < 1 || d > days_in_month[m]) return false;
return true;
}
void read() { cin >> s; }
void init() {}
void solve() {
int len = s.size();
for (int i = 0; i <= len - 8; ++i) {
if (isCorrectFormat(i)) {
if (isValidFormat(i)) {
Date x;
x.d = dd;
x.m = mm;
x.y = yy;
mp[x]++;
}
}
}
int tmp_cnt = 0;
map<Date, int>::iterator it;
for (it = mp.begin(); it != mp.end(); ++it) {
Date x = (*it).first;
tmp_cnt = max(tmp_cnt, (*it).second);
}
for (it = mp.begin(); it != mp.end(); ++it) {
if (tmp_cnt == (*it).second) {
Date x = (*it).first;
x.display();
return;
}
}
}
int main() {
int ntest = 1;
int itest = 1;
for (itest = 1; itest <= ntest; ++itest) {
read();
if (exitInput) {
break;
}
init();
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<string> v;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i + 3] == '0') {
if (s[i + 4] == '1' || s[i + 4] == '3' || s[i + 4] == '5' ||
s[i + 4] == '7' || s[i + 4] == '8') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' ||
s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' ||
s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '2') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '2' && s[i + 1] == '9')) {
if (s[i] >= '0' && s[i] <= '2' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '4' || s[i + 4] == '6' || s[i + 4] == '9') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' ||
s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' ||
s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
}
} else if (s[i + 3] == '1') {
if (s[i + 4] == '0' || s[i + 4] == '2') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' ||
s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' ||
s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '1') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' ||
s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' ||
s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
}
}
}
int ma = 0, count = 1;
string t;
sort(v.begin(), v.end());
for (int i = 0; i < v.size() - 1; i++) {
if (v[i] == v[i + 1])
count++;
else {
if (count > ma) t = v[i];
ma = max(ma, count);
count = 1;
}
}
if (count > ma) t = v[v.size() - 1];
cout << t;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char a[1000000];
cin >> a;
int l = strlen(a);
int i, j;
int month;
int year;
int date;
int found[10000][4] = {0};
int founi = 0;
int flag;
int ac[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (i = 2; i < l - 7; i++) {
if (a[i - 2] != '-' && a[i - 1] != '-' && a[i + 0] == '-' &&
a[i + 1] != '-' && a[i + 2] != '-' && a[i + 3] == '-' &&
a[i + 4] != '-' && a[i + 5] != '-' && a[i + 6] != '-' &&
a[i + 7] != '-') {
month = (a[i + 1] - '0') * 10 + (a[i + 2] - '0');
date = (a[i - 2] - '0') * 10 + (a[i - 1] - '0');
year = (a[i + 4] - '0') * 1000 + (a[i + 5] - '0') * 100 +
(a[i + 6] - '0') * 10 + (a[i + 7] - '0');
if (month <= 12 && month >= 1 && year <= 2015 && year >= 2013) {
if (date <= ac[month] && date >= 1) {
flag = 0;
for (j = 0; j < founi; j++) {
if (found[j][0] == year && found[j][1] == month &&
found[j][2] == date) {
flag = 1;
found[j][3]++;
}
}
if (flag == 0) {
found[founi][0] = year;
found[founi][1] = month;
found[founi][2] = date;
found[founi][3] = 1;
founi++;
}
}
}
}
}
int max = -1;
max = -1;
for (i = 0; i < founi; i++) {
if (max < found[i][3]) {
max = found[i][3];
year = found[i][0];
month = found[i][1];
date = found[i][2];
}
}
if (date < 10) {
cout << "0" << date;
} else {
cout << date;
}
cout << '-';
if (month < 10) {
cout << "0" << month;
} else {
cout << month;
}
cout << "-";
cout << year << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string a;
int cnt[40][20][10];
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
cin >> a;
int n = a.size(), mx = 0, ansd = 0, ansm = 0, ansy = 0;
for (int i = 0; i + 9 < n; i++) {
if (a[i] == '-' || a[i + 1] == '-' || a[i + 2] != '-' || a[i + 3] == '-' ||
a[i + 4] == '-' || a[i + 5] != '-' || a[i + 6] != '2' ||
a[i + 7] != '0' || a[i + 8] != '1' || a[i + 9] == '-')
continue;
int dd = (a[i] - 48) * 10 + a[i + 1] - 48;
int mm = (a[i + 3] - 48) * 10 + a[i + 4] - 48;
int yy = a[i + 9] - 48;
if (3 <= yy && yy <= 5 && 1 <= mm && mm <= 12 && 1 <= dd && dd <= m[mm]) {
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ansd = dd;
ansm = mm;
ansy = yy;
}
}
}
printf("%d%d-%d%d-%d\n", ansd / 10, ansd % 10, ansm / 10, ansm % 10,
2010 + ansy);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
string s;
map<string, int> cnt;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans = "0";
void solve(string x) {
if (x[2] != '-' or x[5] != '-') return;
for (int i = 0; i < 10; i++) {
if ((i == 2 or i == 5) and x[i] != '-') return;
if (i == 2 or i == 5) continue;
if (x[i] < '0' or x[i] > '9') return;
}
int day = (x[0] - '0') * 10 + x[1] - '0';
int month = (x[3] - '0') * 10 + x[4] - '0';
int year =
(x[6] - '0') * 1000 + (x[7] - '0') * 100 + (x[8] - '0') * 10 + x[9] - '0';
if (year < 2013 or year > 2015) return;
if (month < 1 or month > 12) return;
if (day < 1 or day > days[month]) return;
if (cnt.find(x) == cnt.end())
cnt[x] = 1;
else
cnt[x]++;
if (cnt[x] > cnt[ans]) ans = x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
cnt["0"] = -1;
for (int i = 0; i + 9 < s.size(); i++) {
solve(s.substr(i, 10));
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans, s;
int len, L;
inline void check(int y, int m, int d) {
string res = "";
for (int i = 1; i <= 4; ++i) {
res += char(y % 10 + '0');
y /= 10;
}
res += '-';
for (int i = 1; i <= 2; ++i) {
res += char(m % 10 + '0');
m /= 10;
}
res += '-';
for (int i = 1; i <= 2; ++i) {
res += char(d % 10 + '0');
d /= 10;
}
reverse(res.begin(), res.end());
if (s.find(res) == string::npos) return;
int book = 0;
for (int i = 0; i < L; ++i) {
if (s.substr(i, 10) == res) {
book++;
if (book > len) {
len = book;
ans = res;
}
}
}
}
int main() {
cin >> s;
L = s.size();
for (int y = 2013; y <= 2015; ++y) {
for (int m = 1; m <= 12; ++m) {
for (int d = 1; d <= mon[m]; ++d) {
check(y, m, d);
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const int maxn = 1000;
int c, mx, mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string mxs, s, ans[1001];
map<string, int> u;
bool find(string x) {
for (int i = 0; i < x.size(); i++) {
if (x[i] == '-' && i != 2 && i != 5) return false;
if (i == 2 || i == 5) {
if (x[i] != '-') return false;
}
}
int dd;
dd = (x[0] - 48) * 10 + (x[1] - 48);
int mm;
mm = (x[3] - 48) * 10 + (x[4] - 48);
int yy;
yy = (x[6] - 48) * 1000 + (x[7] - 48) * 100 + (x[8] - 48) * 10 + (x[9] - 48);
if (yy < 2013 || yy > 2015) return false;
if (dd > mon[mm] || dd <= 0) return false;
return true;
}
int main() {
cin >> s;
for (int i = 0; i < s.length(); i++) {
string st = "";
for (int j = i; j < i + 10; j++) {
st += s[j];
}
if (find(st)) {
if (u[st] == 0) ans[++c] = st;
u[st]++;
}
}
for (int i = 1; i <= c; i++) {
if (u[ans[i]] > mx) {
mx = u[ans[i]];
mxs = ans[i];
}
}
cout << mxs;
return 0;
}
|
#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T &a) {
return a * a;
}
template <typename T>
T inline ABS(const T &a) {
return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
int ndays[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
string s;
cin >> s;
map<string, int> occ;
int i = 0, j = 9;
while (j < int((s).size())) {
if (s[i + 2] == s[i + 5] && s[i + 5] == '-') {
int mm = -1, dd = -1, yy = -1;
if (s[i] != '-' && s[i + 1] != '-') {
dd = 10 * (s[i] - '0') + (s[i + 1] - '0');
}
if (s[i + 3] != '-' && s[i + 4] != '-') {
mm = 10 * (s[i + 3] - '0') + (s[i + 4] - '0');
}
if (s[i + 6] != '-' && s[i + 7] != '-' && s[i + 8] != '-' &&
s[i + 9] != '-') {
yy = 1000 * (s[i + 6] - '0') + 100 * (s[i + 7] - '0') +
10 * (s[i + 8] - '0') + (s[i + 9] - '0');
}
if ((mm != -1) && (dd != -1) && (yy != -1)) {
if (2013 <= yy && yy <= 2015) {
if (1 <= mm && mm <= 12) {
if (1 <= dd && dd <= ndays[mm]) {
occ[s.substr(i, 10)]++;
}
}
}
}
}
i++, j++;
}
int mx = -1;
string res;
for (__typeof((occ).begin()) dt = occ.begin(); dt != occ.end(); dt++) {
if (dt->second > mx) {
mx = dt->second;
res = dt->first;
}
}
cout << res << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int stoi(string &s) {
int n = 0;
for (int i = 0; i < s.size(); i++) {
n *= 10;
n += s[i] - 48;
}
return n;
}
string itos(int n) {
string s;
s.push_back(n / 10 + 48);
s.push_back(n % 10 + 48);
return s;
}
int date[32][13][3];
int main() {
string s;
cin >> s;
int d, m, y;
for (int i = 6; i < s.size() - 3; i++) {
string yyyy = s.substr(i, 4);
if (yyyy == "2013" || yyyy == "2014" || yyyy == "2015") {
if (s[i - 1] != '-') continue;
if (s[i - 2] == '-') continue;
if (s[i - 3] == '-') continue;
if (s[i - 4] != '-') continue;
if (s[i - 5] == '-') continue;
if (s[i - 6] == '-') continue;
y = stoi(yyyy);
string dd = s.substr(i - 6, 2);
string mm = s.substr(i - 3, 2);
d = stoi(dd);
m = stoi(mm);
switch (m) {
case 1:
if (d > 31) d = -1;
break;
case 2:
if (d > 28) d = -1;
break;
case 3:
if (d > 31) d = -1;
break;
case 4:
if (d > 30) d = -1;
break;
case 5:
if (d > 31) d = -1;
break;
case 6:
if (d > 30) d = -1;
break;
case 7:
if (d > 31) d = -1;
break;
case 8:
if (d > 31) d = -1;
break;
case 9:
if (d > 30) d = -1;
break;
case 10:
if (d > 31) d = -1;
break;
case 11:
if (d > 30) d = -1;
break;
case 12:
if (d > 31) d = -1;
break;
default:
d = -1;
break;
}
if (d == -1 || d == 0) continue;
date[d][m][y - 2013]++;
}
}
int t = 0;
for (int i = 0; i < 32; i++)
for (int j = 0; j < 13; j++)
for (int k = 0; k < 3; k++)
if (t < date[i][j][k]) {
d = i;
m = j;
y = k + 2013;
t = date[i][j][k];
}
string dd = itos(d);
string mm = itos(m);
cout << dd << "-" << mm << "-" << y;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int64_t m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
map<string, int64_t> date;
string s;
cin >> s;
s = "00" + s;
int64_t n = s.length();
for (int64_t i = 0; i < n - 8; ++i) {
string a = s.substr(i, 9);
if (count((a).begin(), (a).end(), '-') == 2 and a[2] == '-' and
a[4] == '-') {
int64_t day = stoi(a.substr(0, 2));
int64_t month = stoi(a.substr(3, 1));
int64_t year = stoi(a.substr(5, 4));
if (month >= 1 and month <= 12 and day >= 1 and day <= m[month - 1] and
year >= 2013 and year <= 2015) {
string real;
real += a[0], real += a[1], real += '-', real += '0', real += a[3],
real += '-', real += a.substr(5, 4);
date[real]++;
cout << a << '\n';
}
}
}
for (int64_t i = 0; i < n - 9; ++i) {
string a = s.substr(i, 10);
if (count((a).begin(), (a).end(), '-') == 2 and a[2] == '-' and
a[5] == '-') {
int64_t day = stoi(a.substr(0, 2));
int64_t month = stoi(a.substr(3, 2));
int64_t year = stoi(a.substr(6, 4));
if (month >= 1 and month <= 12 and day >= 1 and day <= m[month - 1] and
year >= 2013 and year <= 2015) {
string real;
real += a.substr(0, 2), real += '-', real += a.substr(3, 2),
real += '-', real += a.substr(6, 4);
date[real]++;
}
}
}
int64_t best = 0;
string val;
for (auto& x : date) {
if (x.second >= best) {
best = x.second;
val = x.first;
}
}
cout << val;
}
|
#include <bits/stdc++.h>
using namespace std;
string str, s, rezz, datums[40005];
int i, j, k, d, m, y, n, z, rez;
int monthdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mas[40005], bijan[40005];
int main() {
cin >> str;
k = str.length() - 9;
for (i = 0; i < k; ++i) {
s = str.substr(i, 10);
m = 0;
for (j = 0; j < 10; ++j) {
if (s[j] == '-') {
++m;
}
}
if (((m == 2) && (s[2] == '-')) && (s[5] == '-')) {
d = (s[0] - '0') * 10 + s[1] - '0';
m = (s[3] - '0') * 10 + s[4] - '0';
y = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] -
'0';
if ((((y >= 2013) && (y <= 2015)) &&
((m <= 12) && (d <= monthdays[m]))) &&
((d > 0) && (m > 0))) {
n = (2016 - y) * 10000 + m * 100 + d;
++mas[n];
if (mas[n] == 1) {
bijan[z] = n;
datums[z] = s;
++z;
}
rez = max(rez, mas[n]);
}
}
}
for (i = 0; i < z; ++i) {
if (mas[bijan[i]] == rez) {
cout << datums[i];
}
}
return 0;
}
|
#include <bits/stdc++.h>
char str[100001];
int num[32][13][2020];
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int isnum(char c) {
if (c >= '0' && c <= '9')
return 1;
else
return 0;
}
int isleap(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return 1;
else
return 0;
}
int main() {
while (scanf("%s", str) != EOF) {
memset(num, 0, sizeof(num));
int month, year, day, dcount = 0;
month = 0, year = 0, day = 0;
int len = strlen(str), ans = 0, y = 0, m = 0, d = 0;
for (int i = 0; i < len; i++) {
if (isnum(str[i]) && (i + 9) < len) {
if (isnum(str[i + 1]) && !isnum(str[i + 2]) && isnum(str[i + 3]) &&
isnum(str[i + 4]) && !isnum(str[i + 5]) && isnum(str[i + 6]) &&
isnum(str[i + 7]) && isnum(str[i + 8]) && isnum(str[i + 9])) {
day = (str[i] - '0') * 10 + str[i + 1] - '0';
if (day > 31 || day == 0) continue;
month = (str[i + 3] - '0') * 10 + str[i + 4] - '0';
if (day > months[month]) continue;
if (month > 12) continue;
year = (str[i + 6] - '0') * 1000 + (str[i + 7] - '0') * 100 +
(str[i + 8] - '0') * 10 + str[i + 9] - '0';
if (year < 2013 || year > 2015) continue;
num[day][month][year]++;
if (ans < num[day][month][year]) {
d = day;
m = month;
y = year;
ans = num[day][month][year];
}
}
}
}
if (d < 10)
printf("0%d-", d);
else
printf("%d-", d);
if (m < 10)
printf("0%d-", m);
else
printf("%d-", m);
printf("%d\n", y);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int y, m, d, j, n = 0, i,
day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
string x, v, s;
int main() {
cin >> s;
for (i = 0; i + 10 <= s.size(); i++) {
x = s.substr(i, 10);
if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 || d > day[m])
continue;
mp[x]++;
if (n < mp[x]) n = mp[x], v = x;
}
cout << v;
}
|
#include <bits/stdc++.h>
using namespace std;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> m;
bool isok(char *ss) {
int i = 0, cnt = 0;
for ((i) = 0; (i) < (10); (i)++) {
if (!isdigit(*(ss + i))) cnt++;
}
if (cnt == 2 && *(ss + 2) == '-' && *(ss + 5) == '-') return true;
return false;
}
bool isvalid(char *ss) {
int d, m, y;
sscanf(ss, "%2d%*c%2d%*c%4d", &d, &m, &y);
return (y >= 2013 && y <= 2015) && (m > 0 && m <= 12) &&
(d >= 1 && d <= days[m - 1]);
}
char s[100005];
int main() {
scanf("%s", s);
int n = strlen(s), i, mx = 0, j;
string ans;
for ((i) = 0; (i) < (n - 9); (i)++) {
if (isok(s + i) && isvalid(s + i)) {
string a = "";
for ((j) = 0; (j) < (10); (j)++) a.push_back(s[j + i]);
if (m.find(a) == m.end())
m[a] = 1;
else
m[a]++;
if (m[a] > mx) {
mx = m[a];
ans = a;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
struct date {
int d;
int m;
int y;
};
int* maxdm(void) {
int i = 0;
int* mdm = (int*)malloc(13 * sizeof(int));
for (i = 1; i < 13; i++) {
mdm[i] = 30;
if (i < 8) {
if (i % 2 == 0) {
if (i == 2) {
mdm[i] = 28;
} else {
mdm[i] = 30;
}
} else {
mdm[i] = 31;
}
} else {
if (i % 2 == 0) {
mdm[i] = 31;
} else {
mdm[i] = 30;
}
}
}
return mdm;
}
int isdigit(char c) {
if (c < 58 && c > 47) {
return 1;
} else {
return 0;
}
}
int dateiscorrect(int d, int m, int y, int* mdm) {
if (m < 0 || m > 12 || y > 2015 || y < 2013 || d < 1) {
return 0;
} else {
if (mdm[m] >= d) {
return 1;
} else {
return 0;
}
}
}
int main(void) {
int* mdm = maxdm();
char* s = (char*)malloc(100000);
scanf("%s", s);
int d, m, y;
int i = 0;
int nb = 0;
int tab[12 * 31 * 3];
for (i = 0; i < 12 * 31 * 3; i++) {
tab[i] = 0;
}
i = 0;
while (s[i + 9] != '\0') {
if (isdigit(s[i + 0]) && isdigit(s[i + 1]) && isdigit(s[i + 3]) &&
isdigit(s[i + 4]) && isdigit(s[i + 6]) && isdigit(s[i + 7]) &&
isdigit(s[i + 8]) && isdigit(s[i + 9]) && s[i + 2] == '-' &&
s[i + 5] == '-') {
int d = (s[i + 0] - 48) * 10 + (s[i + 1] - 48);
int m = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
int y = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 +
(s[i + 8] - 48) * 10 + (s[i + 9] - 48);
if (dateiscorrect(d, m, y, mdm)) {
tab[d - 1 + (m - 1) * 31 + (y - 2013) * 372]++;
nb++;
}
}
i++;
}
int pmax = 0;
int max = 0;
int tmp = 0;
for (i = 0; i < 12 * 31 * 3; i++) {
if (tab[i] > max) {
max = tab[i];
pmax = i;
}
}
y = 2013 + pmax / 372;
m = (pmax % 372) / 31 + 1;
d = ((pmax % 372) % 31) + 1;
if (d < 10) {
printf("0");
}
printf("%d-", d);
if (m < 10) {
printf("0");
}
printf("%d-", m);
printf("%d", y);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char str[100005], res[15], Max[15];
char temp[15] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int len, i, j, t, max, day, mon, year;
while (gets(str)) {
map<string, int> num;
len = strlen(str);
for (i = 0, max = 0; i < len - 9; i++) {
if (str[i + 2] == '-' && str[i + 5] == '-') {
memset(res, 0, sizeof(res));
for (j = 0; j < 10; j++) {
if (j != 2 && j != 5 && str[j + i] == '-') break;
res[j] = str[i + j];
}
if (j >= 10) {
res[10] = '\0';
year = (((str[i + 6] - '0') * 10 + str[i + 7] - '0') * 10 +
str[i + 8] - '0') *
10 +
str[i + 9] - '0';
if (year > 2015 || year < 2013) continue;
mon = (str[i + 3] - '0') * 10 + str[i + 4] - '0';
if (mon > 12 || mon < 1) continue;
day = (str[i] - '0') * 10 + str[i + 1] - '0';
if (day > temp[mon - 1] || day < 1) continue;
num[res]++;
if (max < num[res]) {
max = num[res];
strcpy(Max, res);
}
}
}
}
printf("%s\n", Max);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int q = 0, w = 0, e = 0;
string p = "";
string s;
cin >> s;
vector<pair<int, string>> a;
vector<int> b = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
a.push_back(make_pair(-1000000, "kek"));
for (int i = 0; i < s.length(); i++) {
if (s[i] != '-' && i + 9 < s.length() && s[i + 1] != '-' &&
s[i + 2] == '-' && s[i + 3] != '-' && s[i + 4] != '-' &&
s[i + 5] == '-' && s[i + 6] != '-' && s[i + 7] != '-' &&
s[i + 8] != '-' && s[i + 9] != '-') {
p = "";
p.push_back(s[i]);
p.push_back(s[i + 1]);
p.push_back(s[i + 2]);
p.push_back(s[i + 3]);
p.push_back(s[i + 4]);
p.push_back(s[i + 5]);
p.push_back(s[i + 6]);
p.push_back(s[i + 7]);
p.push_back(s[i + 8]);
p.push_back(s[i + 9]);
for (int j = 0; j < a.size(); j++) {
if (a[j].second != p && j == a.size() - 1) {
a.push_back(make_pair(1, p));
if (((int(p[0]) - '0') * 10 + int(p[1]) - '0') == 0 ||
((int(p[3]) - '0') * 10 + int(p[4]) - '0') == 0 ||
((int(p[8]) - '0') * 10 + int(p[9]) - '0') > 16 ||
((int(p[8]) - '0') * 10 + int(p[9]) - '0') <= 12 ||
((int(p[3]) - '0') * 10 + int(p[4]) - '0') > 12 ||
b[((int(p[3]) - '0') * 10 + int(p[4]) - '0') - 1] <
((int(p[0]) - '0') * 10 + int(p[1]) - '0'))
a[a.size() - 1].first = -1100000;
break;
} else if (a[j].second == p) {
a[j].first++;
}
}
}
}
sort(a.begin(), a.end());
cout << a[a.size() - 1].second;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
vector<pair<int, string> > vis;
int isCorrect(string s) {
int year, month, day;
if (s[0] == '-' || s[1] == '-' || s[3] == '-' || s[4] == '-' || s[6] == '-' ||
s[7] == '-' || s[8] == '-' || s[9] == '-')
return 0;
if (s[2] != '-' || s[5] != '-') return 0;
day = (s[0] - '0') * 10 + s[1] - '0';
month = (s[3] - '0') * 10 + s[4] - '0';
year = 0;
for (int i = 0; i < 4; i++) year = year * 10 + s[6 + i] - '0';
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 && day >= 1 &&
day <= 31 && day <= mon[month])
return 1;
else
return 0;
}
int main() {
string s;
cin >> s;
for (int i = 0; i < s.length() - 9; i++) {
string s1(s, i, 10);
if (isCorrect(s1)) mp[s1]++;
}
for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
vis.push_back(make_pair(it->second, it->first));
sort(vis.begin(), vis.end());
cout << vis[vis.size() - 1].second << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dm(string str) {
int s;
s = (int)str[0] - 48;
s = (s * 10) + (int)str[1] - 48;
return s;
}
int year(string str) {
int s;
s = (int)str[0] - 48;
s = (s * 10) + (int)str[1] - 48;
s = (s * 10) + (int)str[2] - 48;
s = (s * 10) + (int)str[3] - 48;
return s;
}
bool iscorrect(string str) {
if (str[2] != '-' || str[5] != '-') return false;
int d, m, y, cnt = 0;
for (int i = 0; i < str.size(); i++)
if (str[i] == '-') cnt++;
if (cnt > 2) return false;
y = year(str.substr(6, 4));
m = dm(str.substr(3, 2));
d = dm(str.substr(0, 2));
if (y < 2013 || y > 2015) return false;
if (m < 1 || m > 12) return false;
if (d < 1 || d > day[m]) return false;
return true;
}
int main() {
map<string, int> mp;
map<string, int>::iterator it;
string str, tmp;
cin >> str;
mp.clear();
for (int i = 0; i <= str.size() - 10; i++) {
tmp = str.substr(i, 10);
if (iscorrect(tmp)) {
if (mp.find(tmp) == mp.end())
mp[tmp] = 1;
else
mp[tmp]++;
}
}
int max = -1;
for (it = mp.begin(); it != mp.end(); ++it) {
if (it->second > max) {
max = it->second;
tmp = it->first;
}
}
cout << tmp << endl;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 1 << 30;
const int base = 1000 * 1000 * 1000;
const int N = 1100000;
const int DAYS[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[110000] = {};
map<string, int> M;
int len = 0;
void Solve() {
char date[11] = "01-01-2013";
for (int i = 3; i < 6; i++)
for (int j = 1; j < 13; j++)
for (int day = 1; day <= DAYS[j - 1]; day++) {
date[0] = day / 10 + '0';
date[1] = day % 10 + '0';
date[3] = j / 10 + '0';
date[4] = j % 10 + '0';
date[9] = i + '0';
int Count = 0;
for (int k = 0; k < len - 9; k++)
if (strncmp(&s[k], date, 10) == 0) Count++;
M[date] = Count;
}
}
int main() {
gets(s);
len = strlen(s);
Solve();
string answ;
int Max = -1;
for (map<string, int>::iterator it = M.begin(); it != M.end(); it++)
if (it->second > Max) {
answ = it->first;
Max = it->second;
}
for (int i = 0; i < answ.size(); i++) putchar(answ[i]);
putchar('\n');
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int record[5][20][40];
int main() {
char s[100015];
vector<int> num[3];
int len, m, d, y, ans, M, D, Y;
while (scanf(" %s", s) != EOF) {
for (int i = 0; i < 5; i++)
for (int j = 0; j < 20; j++)
for (int k = 0; k < 40; k++) record[i][j][k] = 0;
len = strlen(s), ans = 0;
for (int i = 0; i < 3; i++) num[i].clear();
s[len++] = '-';
for (int i = 0; i < len; i++) {
if (s[i] == '-') {
if (num[0].size() > 0 && num[1].size() == 2 && num[2].size() > 0) {
if (num[0].size() >= 2)
d = num[0][num[0].size() - 2] * 10 + num[0][num[0].size() - 1];
m = num[1][0] * 10 + num[1][1];
y = 0;
for (int x = 0; x < 4; x++) y = y * 10 + num[2][x];
if (2013 <= y && y <= 2015 && 1 <= m && m <= 12 && 1 <= d &&
d <= day[m]) {
record[y - 2013][m][d]++;
if (record[y - 2013][m][d] > ans) {
ans = record[y - 2013][m][d];
M = m;
D = d;
Y = y;
}
}
}
num[0] = num[1];
num[1] = num[2];
num[2].clear();
} else {
num[2].push_back(s[i] - '0');
}
}
printf("%02d-%02d-%d\n", D, M, Y);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string str;
struct node {
string tt;
int c;
};
map<string, int> vis;
node nodes[1000008];
int cnt;
bool check(int dd, int mm) {
if (dd <= 0) return false;
if (mm <= 0) return false;
if (mm == 2) {
if (dd <= 28)
return true;
else
return false;
}
if (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 ||
mm == 12) {
if (dd <= 31)
return true;
else
return false;
}
if (mm == 2 || mm == 4 || mm == 6 || mm == 9 || mm == 11) {
if (dd <= 30)
return true;
else
return false;
}
return false;
}
void findS(int s) {
string tmp;
int dd, yy, mm;
if (s < 2) return;
if (str[s - 1] >= '0' && str[s - 1] <= '9' && str[s - 2] <= '9' &&
str[s - 2] >= '0') {
dd = (int)(str[s - 2] - '0') * 10 + (int)(str[s - 1] - '0');
if (str[s + 1] >= '0' && str[s + 1] <= '9' && str[s + 2] >= '0' &&
str[s + 2] <= '9') {
mm = (str[s + 1] - '0') * 10 + (str[s + 2] - '0');
if (!check(dd, mm)) return;
if (str[s + 3] != '-') return;
if (str[s + 4] >= '0' && str[s + 4] <= '9' && str[s + 5] >= '0' &&
str[s + 5] <= '9' && str[s + 6] >= '0' && str[s + 6] <= '9' &&
str[s + 7] >= '0' && str[s + 7] <= '9')
yy = (str[s + 4] - '0') * 1000 + (str[s + 5] - '0') * 100 +
(str[s + 6] - '0') * 10 + str[s + 7] - '0';
else
return;
if (yy < 2013 || yy > 2015) return;
tmp.push_back(str[s - 2]);
tmp.push_back(str[s - 1]);
tmp.push_back(str[s + 1]);
tmp.push_back(str[s + 2]);
tmp.push_back(str[s + 4]);
tmp.push_back(str[s + 5]);
tmp.push_back(str[s + 6]);
tmp.push_back(str[s + 7]);
if (vis[tmp]) {
nodes[vis[tmp]].c++;
} else {
vis[tmp] = ++cnt;
nodes[vis[tmp]].c = 1;
nodes[vis[tmp]].tt = tmp;
}
}
}
}
bool cmp(node a, node b) { return a.c > b.c; }
int main() {
cin >> str;
vis.clear();
cnt = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] == '-') {
findS(i);
}
}
sort(nodes + 1, nodes + 1 + cnt, cmp);
cout << nodes[1].tt[0] << nodes[1].tt[1] << "-" << nodes[1].tt[2]
<< nodes[1].tt[3] << "-" << nodes[1].tt[4] << nodes[1].tt[5]
<< nodes[1].tt[6] << nodes[1].tt[7] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int d, m, y, res;
string line, cur, best;
map<string, int> s;
int main() {
res = 0;
getline(cin, line);
for (int i = (0); i < (line.length() + 1); i++) {
cur.clear();
for (int j = (0); j < (10); j++) cur += line[i + j];
if (!isdigit(cur[0]) || !isdigit(cur[1]) || !isdigit(cur[3]) ||
!isdigit(cur[4]) || !isdigit(cur[6]) || !isdigit(cur[7]) ||
!isdigit(cur[8]) || !isdigit(cur[9]) || isdigit(cur[2]) ||
isdigit(cur[5]))
continue;
d = 10 * (cur[0] - '0') + (cur[1] - '0');
m = 10 * (cur[3] - '0') + (cur[4] - '0');
y = 1000 * (cur[6] - '0') + 100 * (cur[7] - '0') + 10 * (cur[8] - '0') +
(cur[9] - '0');
if (m < 1 || m > 12 || y < 2013 || y > 2015) continue;
if (d < 1) continue;
if (m < 8) {
if (m % 2) {
if (d > 31) continue;
} else {
if (d > 30 || (m == 2 && d > 28)) continue;
}
} else {
if (m % 2) {
if (d > 30) continue;
} else {
if (d > 31) continue;
}
}
map<string, int>::iterator it = s.find(cur);
if (it == s.end()) {
s.insert(make_pair(cur, 1));
if (!res) {
res = 1;
best = cur;
}
} else {
++it->second;
if (it->second > res) {
res = it->second;
best = cur;
}
}
}
cout << best << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int d[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(string a) {
for (int i = 0; i < 10; i++) {
if (i == 2 || i == 5) {
if (a[i] != '-') return false;
} else {
if (a[i] < '0' || a[i] > '9') return false;
}
}
int year = (a[6] - '0') * 1000 + (a[7] - '0') * 100 + (a[8] - '0') * 10 +
(a[9] - '0');
int month = (a[3] - '0') * 10 + (a[4] - '0');
int date = (a[0] - '0') * 10 + (a[1] - '0');
if (year < 2013 || year > 2015) return false;
if (month <= 0 || month > 12) return false;
if (date > d[month] || date <= 0) return false;
return true;
}
int main() {
string s;
cin >> s;
for (int i = 0; i <= s.size() - 10; i++) {
if (check(s.substr(i, 10))) {
m[s.substr(i, 10)]++;
}
}
int maxc = -1;
string id;
for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
if ((it->second) > maxc) {
id = (it->first);
maxc = (it->second);
}
}
cout << id;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void lpss(vector<int> &lps, string &s) {
lps[0] = 0;
lps[1] = 0;
int i = 2, j = 0;
while (i < s.length()) {
if (s[i] == s[j + 1]) {
lps[i] = ++j;
++i;
} else {
if (j != 0)
j = lps[j];
else {
lps[i] = 0;
++i;
}
}
}
}
int chk(string &s, string &p, vector<int> &lps) {
int i = 0, j = 0, c = 0;
while (i < s.length()) {
if (s[i] == p[j + 1]) {
i++;
j++;
if (j == p.length() - 1) {
c++;
j = lps[j];
}
} else {
if (j != 0)
j = lps[j];
else
i++;
}
}
return c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test = 1;
while (test--) {
string s;
cin >> s;
string d[31] = {"01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12", "13", "14", "15", "16",
"17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30", "31"};
string m[12] = {"01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"};
string y[3] = {"2013", "2014", "2015"};
string ans;
ans.reserve(15);
int mx = 0;
for (int dd = 0; dd < 31; dd++) {
for (int mm = 0; mm < 12; mm++) {
for (int yy = 0; yy < 3; yy++) {
if ((mm == 1 && dd <= 27) ||
(((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)) &&
dd <= 29) ||
(mm == 0 || mm == 2 || mm == 4 || mm == 6 || mm == 7 || mm == 9 ||
mm == 11)) {
string p;
p.reserve(15);
p = "#";
p += d[dd];
p += "-";
p += m[mm];
p += "-";
p += y[yy];
vector<int> lps(p.length());
lpss(lps, p);
int c = chk(s, p, lps);
if (c > mx) {
mx = c;
ans = p.substr(1);
}
}
}
}
}
cout << ans;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int kd[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, i, j;
char s[666666];
int cnt[42][42][42];
int mx, ad, am, ay;
int main() {
scanf("%s", s);
int n = strlen(s);
memset(cnt, 0, sizeof(cnt));
for (i = 0; i + 9 < n; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
int ok = 1;
for (j = 0; j < 10; j++)
if (j != 2 && j != 5 && s[i + j] == '-') ok = 0;
if (!ok) continue;
int dd = (s[i] - 48) * 10 + (s[i + 1] - 48);
int mm = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
int yy = s[i + 9] - 48;
if (yy < 3 || yy > 5) continue;
if (mm < 1 || mm > 12) continue;
if (dd < 1 || dd > kd[mm]) continue;
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ad = dd;
am = mm;
ay = yy;
}
}
printf("%d%d-%d%d-%d\n", ad / 10, ad % 10, am / 10, am % 10, 2010 + ay);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s, k;
cin >> s;
map<string, int> m;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i] != '-' && s[i + 1] != '-' && s[i + 2] == '-' && s[i + 3] != '-' &&
s[i + 4] != '-' && s[i + 5] == '-' && s[i + 6] != '-' &&
s[i + 7] != '-' && s[i + 8] != '-' && s[i + 9] != '-') {
if (s[i + 6] == '2' && s[i + 7] == '0' && s[i + 8] == '1' &&
s[i + 9] >= '3' && s[i + 9] <= '5') {
if ((s[i + 3] == '0' &&
(s[i + 4] == '1' || s[i + 4] == '8' || s[i + 4] == '7' ||
s[i + 4] == '5' || s[i + 4] == '3')) ||
(s[i + 3] == '1' && (s[i + 4] == '0' || s[i + 4] == '2'))) {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '3' && s[i] > '0') ||
(s[i] == '3' && (s[i + 1] == '1' || s[i + 1] == '0'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
} else if ((s[i + 3] == '0' &&
(s[i + 4] == '4' || s[i + 4] == '6' || s[i + 4] == '9')) ||
(s[i + 3] == '1' && (s[i + 4] == '1'))) {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '3' && s[i] > '0') ||
(s[i] == '3' && (s[i + 1] == '0'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
} else if (s[i + 3] == '0' && s[i + 4] == '2') {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '2' && s[i] > '0') ||
(s[i] == '2' && (s[i + 1] >= '0' && s[i + 1] <= '8'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
}
}
}
}
map<string, int>::iterator it = m.begin();
int maxx = -1;
for (; it != m.end(); it++) {
if (maxx < it->second) {
maxx = it->second;
s = it->first;
}
}
cout << s;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5 + 5);
const int INF = 1e9 + 7;
int d[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s;
vector<int> prefix_function(string s) {
int n = (int)s.length();
vector<int> pi(n);
for (int i = 1; i < n; ++i) {
int j = pi[i - 1];
while (j > 0 && s[i] != s[j]) j = pi[j - 1];
if (s[i] == s[j]) ++j;
pi[i] = j;
}
return pi;
}
int calc(string x) {
string t = x + '#' + s;
vector<int> p = prefix_function(t);
int res = 0;
for (int i : p) {
if (i == x.size()) {
++res;
}
}
return res;
}
string get(int a, int b, int c) {
string res, res1, res2, res3;
if (c < 10) {
res += '0';
}
while (c) {
int x = c % 10;
res1 += char(x + '0');
c /= 10;
}
reverse(res1.begin(), res1.end());
res += res1;
res += '-';
if (b < 10) {
res += '0';
}
while (b) {
int x = b % 10;
res2 += char(x + '0');
b /= 10;
}
reverse(res2.begin(), res2.end());
res += res2;
res += '-';
while (a) {
int x = a % 10;
res3 += char(x + '0');
a /= 10;
}
reverse(res3.begin(), res3.end());
res += res3;
return res;
}
int main() {
cin >> s;
string ans;
int mx = 0;
for (int i = 2013; i <= 2015; ++i) {
for (int j = 1; j <= 12; ++j) {
for (int t = 1; t <= d[j - 1]; ++t) {
string cur = get(i, j, t);
if (calc(cur) > mx) {
mx = calc(cur);
ans = cur;
}
}
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
typedef struct coor {
int x, y;
};
int nomalDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leapDay[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int ARRSIZE = 100100;
const int STRSIZE = 100100;
const int GRIDSIZE = 510;
const int MAXINF = (2 << 20);
const int MININF = (~(2 << 20));
inline bool upcmp(int a, int b) { return a < b; }
inline bool downcmp(int a, int b) { return a > b; }
int hs[50][50][10];
int main() {
string s, res;
cin >> s;
int i, j, len = (int)s.size(), Max = MININF;
for (i = 0; i < len - 8; i++) {
string tp = "";
int cnt = 0;
for (j = 0; j < 10; j++) {
tp += s[i + j];
if (s[i + j] == '-') cnt++;
}
if (cnt > 2) continue;
int day = (tp[0] - '0') * 10 + tp[1] - '0';
int mon = (tp[3] - '0') * 10 + tp[4] - '0';
int year = (tp[6] - '0') * 1000 + (tp[7] - '0') * 100 + (tp[8] - '0') * 10 +
tp[9] - '0';
if (tp[2] != '-' || tp[5] != '-') continue;
if (year < 2013 || year > 2015) continue;
if (mon < 1 || mon > 12) continue;
if (day > nomalDay[mon] || day < 1) continue;
int h1 = hs[day][mon][year - 2013]++;
h1++;
if (h1 > Max) {
res = tp;
Max = h1;
}
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
tuple<int, int, string> dates(0, 0, "fine");
map<tuple<int, int, string>, int> mp;
int day, month;
string year;
bool check_month(char a, char b) {
if (a == '-' || b == '-') return false;
month = (int)a - (int)'0';
int y = (int)b - (int)'0';
month *= 10;
month += y;
if (month >= 1 && month <= 12) return true;
return false;
}
bool is_day(char a, char b) {
if (a == '-' || b == '-') return false;
if (a == '0' && b == '0') return false;
day = (int)a - (int)'0';
day *= 10;
day += (int)b - (int)'0';
return (day <= months[month - 1]);
}
bool check_year(string nyear) {
year = nyear;
return (nyear == "2013" || nyear == "2014" || nyear == "2015");
}
void add_tomap() {
tuple<int, int, string> news(day, month, year);
mp[news]++;
if (mp[news] > mp[dates]) dates = news;
}
int main() {
string s;
cin >> s;
for (int i = 2; i < s.length() - 5; i++) {
if (s[i] == '-' && s[i + 3] == '-' && check_month(s[i + 1], s[i + 2]) &&
is_day(s[i - 2], s[i - 1]) && check_year(s.substr(i + 4, 4))) {
add_tomap();
}
}
(get<0>(dates) < 10) ? cout << 0 << get<0>(dates) : cout << get<0>(dates);
cout << "-";
(get<1>(dates) < 10) ? cout << 0 << get<1>(dates) : cout << get<1>(dates);
cout << "-";
cout << get<2>(dates);
}
|
#include <bits/stdc++.h>
using namespace std;
bool prime[100000 + 1];
void sieve() {
memset(prime, true, sizeof(prime));
for (long p = 2; p * p <= 100000; p++) {
if (prime[p] == true) {
for (long i = p * p; i <= 100000; i += p) prime[i] = false;
}
}
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long power(int v, int a) {
long prod = 1;
for (int i = 0; i < a; i++) prod *= v;
return prod;
}
int countFreq(string &pat, string &txt) {
int M = pat.length();
int N = txt.length();
int res = 0;
for (int i = 0; i <= N - M; i++) {
int j;
for (j = 0; j < M; j++)
if (txt[i + j] != pat[j]) break;
if (j == M) {
res++;
j = 0;
}
}
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T = 1;
while (T--) {
string s;
vector<string> v;
int d[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 2013; i <= 2015; i++) {
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= d[j - 1]; k++) {
string temp = "";
if (k / 10 == 0) temp += "0";
temp += to_string(k) + "-";
if (j / 10 == 0) temp += "0";
temp += to_string(j) + "-";
temp += to_string(i);
v.push_back(temp);
}
}
}
cin >> s;
int ans = 0;
string final;
for (int i = 0; i < v.size(); i++) {
int t = countFreq(v[i], s);
if (ans < t) {
ans = t;
final = v[i];
}
}
cout << final;
}
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[100100];
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int toInt(int i, int n) {
int res = 0;
for (int j = (0); j < ((n)); ++j) res = 10 * res + (s[i + j] - '0');
return res;
}
bool good(int i) {
if (s[i + 2] != '-' || s[i + 5] != '-') return false;
for (int j = (0); j < ((10)); ++j)
if (j != 2 && j != 5)
if (s[i + j] == '-') return false;
int d = toInt(i, 2), m = toInt(i + 3, 2), y = toInt(i + 6, 4);
if (y < 2013 || y > 2015) return false;
if (m < 1 || m > 12) return false;
if (d < 1 || d > days[m - 1]) return false;
return true;
}
int main() {
scanf("%s", s);
int n = strlen(s);
map<string, int> cnt;
for (int i = (0); i < ((n - 9)); ++i)
if (good(i)) {
string ss(s + i, s + i + 10);
++cnt[ss];
}
int mx = 0;
for (map<string, int>::const_iterator i = cnt.begin(); i != cnt.end(); ++i)
mx = max(mx, i->second);
for (map<string, int>::const_iterator i = cnt.begin(); i != cnt.end(); ++i)
if (i->second == mx) {
cout << i->first << endl;
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793238;
const int M = 1e9 + 7;
const int Nmax = 5005;
const int MM = 1e7 + 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
while (T--) {
set<string> ss;
string s;
cin >> s;
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 2013; i <= 2015; i++) {
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= day[j - 1]; k++) {
string date = "";
if (k < 10) date += '0';
date += to_string(k);
date += '-';
if (j < 10) date += '0';
date += to_string(j);
date += '-';
date += to_string(i);
ss.insert(date);
}
}
}
map<string, int> m;
for (int i = 0; i <= s.size() - 10; i++) {
string k = s.substr(i, 10);
if (ss.count(k)) m[k]++;
}
int mx = 0;
string ans;
for (auto x : m) {
if (x.second > mx) {
ans = x.first;
mx = x.second;
}
}
cout << ans;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<string> A;
for (int I = 0; I < s.length() - 9; I += 1) {
string sub = s.substr(I, 10);
bool ValidDM = false;
int Day = 0;
if (sub[0] == '0') {
Day = sub[1] - '0';
} else
Day = (sub[0] - '0') * 10 + (sub[1] - '0');
int Mon = 0;
if (sub[3] == '0') {
Mon = sub[4] - '0';
} else
Mon = (sub[3] - '0') * 10 + (sub[4] - '0');
if (sub[0] >= '0' && sub[0] <= '9' && sub[1] >= '0' && sub[1] <= '9' &&
sub[3] >= '0' && sub[3] <= '9' && sub[4] >= '0' && sub[4] <= '9') {
if (Mon == 1)
if (Day <= 31) ValidDM = true;
if (Mon == 2)
if (Day <= 28) ValidDM = true;
if (Mon == 3)
if (Day <= 31) ValidDM = true;
if (Mon == 4)
if (Day <= 30) ValidDM = true;
if (Mon == 5)
if (Day <= 31) ValidDM = true;
if (Mon == 6)
if (Day <= 30) ValidDM = true;
if (Mon == 7)
if (Day <= 31) ValidDM = true;
if (Mon == 8)
if (Day <= 31) ValidDM = true;
if (Mon == 9)
if (Day <= 30) ValidDM = true;
if (Mon == 10)
if (Day <= 31) ValidDM = true;
if (Mon == 11)
if (Day <= 30) ValidDM = true;
if (Mon == 12)
if (Day <= 31) ValidDM = true;
} else
continue;
if (Day == 0) continue;
bool ValidY = false;
if (sub[6] == '2' && sub[7] == '0' && sub[8] == '1' &&
(sub[9] == '3' || sub[9] == '4' || sub[9] == '5'))
ValidY = true;
bool ValidOther = false;
if (sub[2] == '-' && sub[5] == '-') ValidOther = true;
if (ValidOther && ValidY && ValidDM) {
A.push_back(sub);
continue;
}
}
int maxT = 0;
int res;
for (int I = 0; I < A.size(); I += 1) {
int occ = 0;
for (int T = 0; T < A.size(); T += 1) {
if (A[I] == A[T]) occ += 1;
}
if (occ > maxT) {
maxT = occ;
res = I;
}
}
cout << A[res];
}
|
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e6;
int str2int(string str) {
stringstream ss(str);
int val;
ss >> val;
return (val);
}
string int2str(int num) {
stringstream ss;
string ans;
ss << num;
ans = ss.str();
return ans;
}
const bool testing = 0;
const int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void program() {
string str;
cin >> str;
map<string, int> ans;
for (int i = 0; i < str.length() - 9; i++) {
string temp = str.substr(i, 10);
bool bad = 0;
for (int j = 0; j < 10; j++)
if (j != 2 && j != 5)
if (!isdigit(temp[j])) {
bad = 1;
break;
}
if (bad) continue;
int d = str2int(temp.substr(0, 2)), m = str2int(temp.substr(3, 2)),
y = str2int(temp.substr(6, 4));
char ch1 = temp[2], ch2 = temp[5];
if (ch1 == '-' && ch2 == '-') {
if (y > 2012 && y < 2016)
if (m >= 1 && m <= 12)
if (d >= 1 && d <= day[m])
if (ans.find(temp) != ans.end())
ans[temp]++;
else
ans[temp] = 1;
}
}
int max = 0;
auto mymax = ans.begin();
for (auto it = ans.begin(); it != ans.end(); it++) {
if (it->second > max) max = it->second, mymax = it;
}
cout << mymax->first;
}
int main() {
if (!testing) {
program();
return 0;
}
FILE* fin = NULL;
fin = fopen("in.txt", "w+");
fprintf(fin, "15-1--201315-1--201301-01-2013\n");
fclose(fin);
freopen("in.txt", "r", stdin);
printf("test case(1) => expected : \n");
printf("13-12-2013");
printf("test case(1) => founded : \n");
program();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char str[123456];
char it[123];
char day[13][5] = {"31", "28", "31", "30", "31", "30",
"31", "31", "30", "31", "30", "31"};
map<string, int> m;
map<string, int>::iterator ut;
int main() {
scanf("%s", str);
int len = strlen(str);
m.clear();
for (int i = 0; i < len - 3; i++) {
if (str[i] == '-' && str[i + 3] == '-' && str[i + 4] == '2' &&
str[i + 5] == '0' && str[i + 6] == '1') {
int flag = 0;
for (int j = 0; j < 10; j++) {
it[j] = str[i + j - 2];
}
it[10] = '\0';
if (it[9] < '3' || it[9] > '5') flag = 1;
if (it[3] < '0' || it[3] > '9' || it[3] > '1') flag = 1;
if (it[3] == '0') {
if (it[4] < '0' || it[4] > '9' || it[4] == '0') flag = 1;
}
if (it[3] == '1') {
if (it[4] < '0' || it[4] > '9' || it[4] > '2') flag = 1;
}
if (it[0] < '0' || it[0] > '9') flag = 1;
if (it[0] == '0') {
if (it[1] <= '0' || it[1] > '9') flag = 1;
} else {
if (it[1] < '0' || it[1] > '9') flag = 1;
}
int u = (it[3] - '0') * 10 + (it[4] - '0');
char t[3];
t[0] = it[0], t[1] = it[1];
t[2] = '\0';
if (strcmp(t, day[u - 1]) > 0) flag = 1;
if (!flag) {
string t = "";
for (int j = 0; j < 10; j++) t += it[j];
m[t]++;
}
}
}
string ans;
int u = -1;
for (ut = m.begin(); ut != m.end(); ut++) {
if (ut->second > u) {
u = ut->second;
ans = ut->first;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
const double pi(3.14159265358979);
const int N = 100100;
const int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char ch[N] = {};
int main() {
gets(ch + 1);
int l = strlen(ch + 1);
map<int, int> bucket;
for (int i = 3; i <= l - 7; ++i)
if (ch[i] == '-' && ch[i + 3] == '-') {
bool flag = isdigit(ch[i - 2]);
flag &= isdigit(ch[i - 1]);
flag &= isdigit(ch[i + 1]);
flag &= isdigit(ch[i + 2]);
flag &= isdigit(ch[i + 4]);
flag &= isdigit(ch[i + 5]);
flag &= isdigit(ch[i + 6]);
flag &= isdigit(ch[i + 7]);
if (!flag) continue;
int d = (ch[i - 2] - '0') * 10 + ch[i - 1] - '0';
int m = (ch[i + 1] - '0') * 10 + ch[i + 2] - '0';
int y = (((ch[i + 4] - '0') * 10 + (ch[i + 5] - '0')) * 10 + ch[i + 6] -
'0') *
10 +
ch[i + 7] - '0';
if (2013 <= y && y <= 2015 && 1 <= m && m <= 12 && 1 <= d &&
d <= month[m])
++bucket[d * 1000000 + m * 10000 + y];
}
int d1 = 0, m1 = 0, y1 = 0, t = 0;
for (auto p : bucket)
if (p.second > t)
d1 = p.first / 1000000, m1 = p.first % 1000000 / 10000,
y1 = p.first % 10000, t = p.second;
printf("%02d-%02d-%d\n", d1, m1, y1);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
long long int Months[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, long long int> checking;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
bool ffllg = 0;
for (long long int i = 0; i <= s.length() - 10; i++) {
long long int cnt = 1;
bool datecheck = 1, check = 1, monthchck = 1, yearcheck = 1;
string ss = "";
long long int end = i + 10;
for (long long int j = i; j < end; j++) {
if (cnt <= 2) {
if (s[j] == '-') {
datecheck = 0;
continue;
}
long long int digit = s[j] - '0';
if (cnt == 1 && ((digit > 3))) {
datecheck = 0;
}
}
if (cnt == 3) {
if (s[j] != '-') check = 0;
}
if (cnt > 3 && cnt < 6) {
if (s[j] == '-') {
monthchck = 0;
continue;
}
long long int digit = s[j] - '0';
if (cnt == 4) {
if (digit > 1) monthchck = 0;
}
}
if (cnt == 6) {
if (s[j] != '-') check = 0;
}
if (cnt == 7) {
if (s[j] == '-') {
yearcheck = 0;
continue;
}
if (s[j] != '2') yearcheck = 0;
}
if (cnt == 8) {
if (s[j] == '-') {
yearcheck = 0;
continue;
}
if (s[j] != '0') yearcheck = 0;
}
if (cnt == 9) {
if (s[j] == '-') {
yearcheck = 0;
continue;
}
if (s[j] != '1') yearcheck = 0;
}
if (cnt == 10) {
if (s[j] == '-') {
yearcheck = 0;
continue;
}
long long int digit = s[j] - '0';
if (digit < 3 || digit > 5) yearcheck = 0;
}
cnt++;
ss += s[j];
}
if (ss[0] == '0' && ss[1] == '0') datecheck = 0;
if (ss[3] == '0' && ss[4] == '0') monthchck = 0;
if (yearcheck && monthchck && datecheck && check) {
long long int date = (ss[0] - '0') * 10 + (ss[1] - '0');
long long int month = (ss[3] - '0') * 10 + (ss[4] - '0');
if (Months[month] >= date) {
checking[ss]++;
ffllg = 1;
}
}
}
long long int maxi = INT_MIN;
string ssss = "";
for (auto it = checking.begin(); it != checking.end(); it++) {
if (it->second > maxi) {
maxi = it->second;
ssss = it->first;
}
}
cout << ssss << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool isd(char first) { return '0' <= first && first <= '9'; }
int main(int argc, char **argv) {
string s;
cin >> s;
int N = s.length();
bool f = 0;
int dd, mm, yy;
int dom[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> freq;
for (int i = (0); i < (N - 9); ++i) {
string t = s.substr(i, 10);
int m, d, second;
string sm, sd, sy;
sd = t.substr(0, 2);
sm = t.substr(3, 2);
sy = t.substr(6, 4);
bool ok = 1;
for (int j = (0); j < (sd.size()) && (ok); ++j) ok = isd(sd[j]);
for (int j = (0); j < (sm.size()) && (ok); ++j) ok = isd(sm[j]);
for (int j = (0); j < (sy.size()) && (ok); ++j) ok = isd(sy[j]);
ok &= t[2] == '-' && t[5] == '-';
if (!ok) continue;
sscanf(sd.c_str(), "%d", &d);
sscanf(sm.c_str(), "%d", &m);
sscanf(sy.c_str(), "%d", &second);
if (2012 < second && second < 2016 && 0 < m < 13) {
if (0 < d && d <= dom[m]) {
freq[t]++;
}
}
}
int res = -1;
string sres;
for (typeof(freq.begin()) t = freq.begin(); t != freq.end(); t++)
if (res < t->second) {
res = t->second;
sres = t->first;
} else if (res == t->second) {
int yy, mm, dd;
int second, m, d;
sscanf(t->first.c_str(), "%d-%d-%d", &d, &m, &second);
sscanf(sres.c_str(), "%d-%d-%d", &dd, &mm, &yy);
bool rpl = 0;
if (second > yy)
rpl = 1;
else if (second == yy && m > mm)
rpl = 1;
else if (second == yy && m == mm)
rpl = d > dd;
if (rpl) sres = t->first;
}
cout << sres;
return 0;
}
|
#include <bits/stdc++.h>
const int S[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int DtCvt(char *z, bool *F) {
static const bool H[10] = {0, 0, 1, 0, 0, 1};
if (10 + H != std::mismatch(H, 10 + H, F).first) return -1;
static const int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, m, d;
sscanf(z, "%d", &d), sscanf(3 + z, "%d", &m), sscanf(6 + z, "%4d", &y);
return 0 > (y -= 2013) || 2 < y || !m || 11 < --m || !d || M[m] < d--
? -1
: d + S[m] + 365 * y;
}
void Output(int s) {
int y = 2013 + s / 365, m = std::upper_bound(1 + S, 12 + S, s %= 365) - S,
d = 1 + s - S[m - 1];
printf("%02i-%02i-%i\n", d, m, y);
}
int main(void) {
bool F[100000];
char z[100001];
for (long n, m, S[1095]; gets(z); Output(std::max_element(S, 1095 + S) - S)) {
for (n = -1; z[++n]; F[n] = '-' == z[n])
;
for (memset(S, 0, sizeof(S)), n -= 9; n--;)
if (~(m = DtCvt(n + z, n + F))) ++S[m];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char s[200010];
char s1[20];
int ha[40][40][10];
int maxx[3], max1;
int main() {
memset(ha, 0, sizeof(ha));
cin >> s;
for (int i = 0; i < strlen(s) - 9; ++i) {
int p, q, r;
if (s[i + 5] != '-' || s[i + 2] != '-') continue;
if (!(isdigit(s[i + 0]) && isdigit(s[i + 1])))
continue;
else
p = 10 * (s[i + 0] - 48) + s[i + 1] - 48;
if (!(isdigit(s[i + 3]) && isdigit(s[i + 4])))
continue;
else
q = 10 * (s[i + 3] - 48) + s[i + 4] - 48;
if (!(isdigit(s[i + 6]) && isdigit(s[i + 7]) && isdigit(s[i + 8]) &&
isdigit(s[i + 9])))
continue;
else
r = 1000 * (s[i + 6] - 48) + 100 * (s[i + 7] - 48) +
10 * (s[i + 8] - 48) + s[i + 9] - 48;
if (2013 <= r && r <= 2015 && 1 <= q && q <= 12 && 1 <= p && p <= 31) {
if (p > 31) continue;
if (p > 28 && q == 2)
continue;
else if (p == 31 && (q == 4 || q == 6 || q == 9 || q == 11))
continue;
ha[p][q][r - 2013]++;
if (ha[p][q][r - 2013] > max1) {
max1 = ha[p][q][r - 2013];
maxx[0] = p;
maxx[1] = q;
maxx[2] = r;
}
}
}
printf("%02d-%02d-%d\n", maxx[0], maxx[1], maxx[2]);
}
|
#include <bits/stdc++.h>
using namespace std;
bool validate(string temp) {
if (temp[0] == '-' || temp[1] == '-' || temp[2] != '-' || temp[3] == '-' ||
temp[4] == '-' || temp[5] != '-')
return false;
string d = "", m = "";
d += temp[0];
d += temp[1];
m += temp[3];
m += temp[4];
int mm = atoi(m.c_str());
int dd = atoi(d.c_str());
if (mm > 12 || mm < 1) return false;
switch (mm) {
case 1:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 2:
if (!(dd <= 28 && dd >= 1)) return false;
break;
case 3:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 4:
if (!(dd <= 30 && dd >= 1)) return false;
break;
case 5:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 6:
if (!(dd <= 30 && dd >= 1)) return false;
break;
case 7:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 8:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 9:
if (!(dd <= 30 && dd >= 1)) return false;
break;
case 10:
if (!(dd <= 31 && dd >= 1)) return false;
break;
case 11:
if (!(dd <= 30 && dd >= 1)) return false;
break;
case 12:
if (!(dd <= 31 && dd >= 1)) return false;
break;
}
return true;
}
int main() {
string in;
cin >> in;
string x = "2013", y = "2014", z = "2015";
map<string, int> X;
for (int i = 0; i < in.size(); i++) {
string temp = in.substr(i, 4);
if (strcmp(temp.c_str(), x.c_str()) == 0) {
temp = in.substr(i - 6, 10);
if (validate(temp)) {
if (X.find(temp) == X.end()) {
X[temp] = 1;
} else
X[temp]++;
}
}
if (strcmp(temp.c_str(), y.c_str()) == 0) {
temp = in.substr(i - 6, 10);
if (validate(temp)) {
if (X.find(temp) == X.end()) {
X[temp] = 1;
} else
X[temp]++;
}
}
if (strcmp(temp.c_str(), z.c_str()) == 0) {
temp = in.substr(i - 6, 10);
if (validate(temp)) {
if (X.find(temp) == X.end()) {
X[temp] = 1;
} else
X[temp]++;
}
}
}
map<string, int>::iterator it, ret;
int max = 0;
for (it = X.begin(); it != X.end(); it++) {
if ((*it).second > max) {
max = (*it).second;
ret = it;
}
}
cout << (*ret).first << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000000 + 7;
const long long int N = 10000000 + 6;
int cal[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(int d, int m) {
if (m <= 12 && m > 0) {
if (d >= 1 && d <= cal[m]) return true;
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string st;
cin >> st;
int n = st.size();
unordered_map<string, int> hmap;
for (int i = 0, j = 9; j < n; i++, j++) {
string sub = st.substr(i, 10);
if (sub[2] == '-' && sub[5] == '-') {
if (sub[6] == '2' && sub[7] == '0' && sub[8] == '1' &&
(sub[9] - '3' >= 0 && sub[9] - '3' <= 2)) {
if (isdigit(sub[0]) && isdigit(sub[1]) && isdigit(sub[3]) &&
isdigit(sub[4])) {
string mo = "";
string da = "";
mo = mo + sub[3] + sub[4];
da = da + sub[0] + sub[1];
int month = stoi(mo);
int day = stoi(da);
bool b = check(day, month);
if (b == true) hmap[sub]++;
}
}
}
}
string ans;
int ma = -1;
for (auto it = hmap.begin(); it != hmap.end(); it++) {
if (it->second > ma) {
ans = it->first;
ma = it->second;
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = 4.0 * atan(1.0);
const int inf = 99999999;
const signed long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 111111;
map<int, int> name;
int ansa, ansb, ansc;
char s[maxn];
bool isok(int a, int b, int c) {
if (c < 2013 || c > 2015) return false;
if (a < 1 || a > 31) return false;
if (b < 1 || b > 12) return false;
if (b == 2) {
if (a >= 29) return false;
return true;
}
if (b == 4 || b == 6 || b == 9 || b == 11) {
if (a > 30) return false;
return true;
}
return true;
}
void cop(int a, int b, int c) { ++name[c + b * 10000 + a * 1000000]; }
void check(char *s) {
int a, b, c;
int i;
for (i = 0; s[i]; ++i) {
if (s[i] == '-') break;
}
if (s[i] == NULL) return;
if (isdigit(s[i - 2]) && isdigit(s[i - 1]))
a = (s[i - 2] - '0') * 10 + s[i - 1] - '0';
else
return;
if (isdigit(s[i + 1]) && isdigit(s[i + 2]) && s[i + 3] == '-')
b = (s[i + 1] - '0') * 10 + s[i + 2] - '0';
else
return;
i = i + 4;
if (isdigit(s[i]) && isdigit(s[i + 1]) && isdigit(s[i + 2]) &&
isdigit(s[i + 3]))
c = (s[i] - '0') * 1000 + (s[i + 1] - '0') * 100 + (s[i + 2] - '0') * 10 +
s[i + 3] - '0';
else
return;
if (isok(a, b, c)) cop(a, b, c);
}
void doit() {
int k = -1;
check(s);
int len = strlen(s);
for (int i = 2; i < len; ++i)
if (s[i] == '-') {
check(s + i);
}
map<int, int>::iterator it;
for (it = name.begin(); it != name.end(); ++it) {
if (it->second > k) {
k = it->second;
int z = it->first;
ansc = z % 10000;
z /= 10000;
ansb = z % 100;
z /= 100;
ansa = z;
}
}
printf("%02d-%02d-%d\n", ansa, ansb, ansc);
}
int main() {
scanf("%s", s);
doit();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string input;
map<string, int> cont;
int maxmentioned = 0;
string ans;
cin >> input;
int len = input.size();
for (int i = 2; i < len; ++i) {
if (i + 7 < len && input[i] == '-' && input[i + 3] == '-') {
if (input[i - 1] == '-' || input[i - 2] == '-' || input[i + 1] == '-' ||
input[i + 2] == '-' || input[i + 4] == '-' || input[i + 5] == '-' ||
input[i + 6] == '-' || input[i + 7] == '-')
continue;
int day = (input[i - 2] - '0') * 10 + (input[i - 1] - '0');
int month = (input[i + 1] - '0') * 10 + (input[i + 2] - '0');
int year = (input[i + 4] - '0') * 1000 + (input[i + 5] - '0') * 100 +
(input[i + 6] - '0') * 10 + (input[i + 7] - '0');
if (year < 2013 || year > 2015) continue;
if (month < 1 || month > 12) continue;
if (day < 1 || day > months[month]) continue;
char strdate[15];
sprintf(strdate, "%02d-%02d-%d", day, month, year);
++cont[string(strdate)];
if (cont[string(strdate)] > maxmentioned) {
maxmentioned = cont[string(strdate)];
ans = string(strdate);
}
}
}
cout << ans;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.