text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int d[14] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; bool ifis(int it) { if (s[it + 2] != '-' || s[it + 5] != '-') { return 0; } if (s[it] > '9' || s[it] < '0' || s[it + 1] > '9' || s[it + 1] < '0' || s[it + 3] > '9' || s[it + 3] < '0' || s[it + 4] > '9' || s[it + 4] < '0' || s[it + 6] > '9' || s[it + 6] < '0' || s[it + 7] > '9' || s[it + 7] < '0' || s[it + 8] > '9' || s[it + 8] < '0' || s[it + 9] > '9' || s[it + 9] < '0') { return 0; } if (s[it + 6] != '2' || s[it + 7] != '0' || s[it + 8] != '1' || s[it + 9] < '3' || s[it + 9] > '5') { return 0; } int m = (s[it + 3] - '0') * 10 + s[it + 4] - '0'; if (m > 12 || m < 1) { return 0; } int da = (s[it] - '0') * 10 + s[it + 1] - '0'; if (da > d[m] || da == 0) { return 0; } return 1; } map<string, int> tj; int main() { cin >> s; string n; n = " "; tj[n] = -1; for (int i = 0; i <= s.size() - 9; i++) { if (ifis(i) == 1) { string t = s.substr(i, 10); tj[t]++; n = (tj[t] > tj[n] ? t : n); } } cout << n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; double pi = 3.1415926536; const int oo = (int)1e9; const long long OO = numeric_limits<long long>::max(); int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int di[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dj[] = {1, -1, 0, 0, 1, -1, -1, 1}; int f1[] = {0, 0, 0, 1, 1, 1, -1, -1, -1}; int f2[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string toString(int x) { stringstream ss; string s; ss << x; ss >> s; return s; } int main() { ios_base::sync_with_stdio(false); map<string, int> mymap; vector<string> myDates; for (int i = 2013; i <= 2015; i++) { for (int j = 1; j <= 12; j++) { for (int k = 1; k <= days[j]; k++) { stringstream ss; string year, month, day; day = toString(k); if (((int)(day).size()) == 1) day = "0" + day; month = toString(j); if (((int)(month).size()) == 1) month = "0" + month; year = toString(i); string date = day + month + year; myDates.push_back(date); } } } string s; cin >> s; for (int i = 0; i < ((int)(s).size()); i++) { string str = s.substr(i, 10); int cnt = 0; string date; for (int j = 0; j < ((int)(str).size()); j++) { if (str[j] == '-') cnt++; else date += str[j]; } if (cnt == 2) { mymap[date]++; } } int idx = -1, mx = -1; for (int i = 0; i < ((int)(myDates).size()); i++) { int take = mymap[myDates[i]]; if (take >= mx) { idx = i; mx = take; } } string ans = myDates[idx]; for (int i = 0; i < ((int)(ans).size()); i++) { cout << ans[i]; if (i == 1) { cout << "-"; } if (i == 3) { cout << "-"; } } }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int f[40][20][10]; int dom[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; memset(f, 0, sizeof(f)); int maxi = 0, ansd, ansm, ansy; for (int i = 0; i < s.length(); ++i) { if (s[i + 2] != '-' || s[i + 5] != '-') continue; bool strip = true; for (int j = 0; j < 9; ++j) { if (j != 2 && j != 5 && s[i + j] == '-') strip = false; } if (!strip) continue; if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue; int d = (s[i] - '0') * 10 + s[i + 1] - '0'; int m = (s[i + 3] - '0') * 10 + s[i + 4] - '0'; int y = s[i + 9] - '0'; if (y < 3 || y > 5) continue; if (m < 1 || m > 12) continue; if (d < 1 || d > dom[m - 1]) continue; ++f[d][m][y]; if (maxi < f[d][m][y]) { maxi = f[d][m][y]; ansd = d; ansm = m; ansy = y; } } cout << ansd / 10 << ansd % 10 << '-' << ansm / 10 << ansm % 10 << '-' << "201" << ansy << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool is_valid(string s) { int part = 0; string ans = ""; bool ok = true; int day = 0; int month = 0; int year = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '-') { part++; int num = stoi(ans); ans = ""; if (part == 1) day = num; else if (part == 2) month = num; } else ans += s[i]; } year = stoi(ans); if (year > 2015 || year < 2013) return false; if (month == 0 || month > 12) return false; int arr[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; month--; if (day == 0 || day > arr[month]) return false; return true; } int main() { map<string, int> m; string s; cin >> s; string temp = "dd-mm-yyyy"; int n = s.size(); for (int i = 0; i < n; i++) { int length = n - i; if (length < 10) break; int ptr = i; bool ok = true; for (int j = 0; j < temp.size(); j++, ptr++) { if (temp[j] == 'd' || temp[j] == 'm' || temp[j] == 'y') { if (s[ptr] >= '0' && s[ptr] <= '9') continue; else { ok = false; break; } } else { if (s[ptr] != '-') { ok = false; break; } } } if (ok) { m[s.substr(i, 10)]++; } } int max_num = 0; string ans = ""; for (auto it = m.begin(); it != m.end(); it++) { if (it->second == 0) continue; if (is_valid(it->first)) { if (it->second > max_num) { max_num = it->second; ans = it->first; } } } cout << ans; }
#include <bits/stdc++.h> using namespace std; map<string, int> cnt; string str; int ar[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { cin >> str; for (int i = 0; i < str.size() - 9; i++) { string s = str.substr(i, 10); if (s[0] == '-' || s[1] == '-' || s[2] != '-' || s[3] == '-' || s[4] == '-' || s[5] != '-' || s[6] == '-' || s[7] == '-' || s[8] == '-' || s[9] == '-') continue; int d, m, y; char c; istringstream(s) >> d >> c >> m >> c >> y; if (m < 1 || m > 12) continue; if (d < 1 || d > ar[m - 1]) continue; if (y < 2013 || y > 2015) continue; cnt[s]++; } string x; int mx = 0; for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); it++) { if (mx < it->second) { mx = it->second; x = it->first; } } cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; int main() { while (getline(cin, s)) { int n = (int)s.size(); vector<string> ans; for (int i = 0; i <= n - 10; 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])) { int day = (s[i] - '0') * 10 + s[i + 1] - '0'; int month = (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 && month >= 1 && month <= 12 && day >= 1 && day <= months[month]) ans.push_back(s.substr(i, 10)); } } sort((ans).begin(), (ans).end()); string best = ""; int cnt = 0; int i = 0; while (i < (int)ans.size()) { int c = 1; while (i < (int)ans.size() - 1 && ans[i] == ans[i + 1]) ++i, ++c; if (cnt < c) best = ans[i], cnt = c; ++i; } printf("%s\n", best.c_str()); } return 0; }
#include <bits/stdc++.h> using namespace std; string s; int a[2000] = {}; string r[2000]; const int mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void tr(int p) { int res = true; for (int i = 0; res && i < 10; i++) res = (((i == 2 || i == 5) && s[p + i] == '-') || (i != 2 && i != 5 && s[p + i] != '-')); if (!res) return; int d = (s[p] - '0') * 10 + s[p + 1] - '0', m = (s[p + 3] - '0') * 10 + s[p + 4] - '0', y = (((s[p + 6] - '0') * 10 + s[p + 7] - '0') * 10 + s[p + 8] - '0') * 10 + s[p + 9] - '0'; if (y >= 2013 && y <= 2015 && m >= 1 && m <= 12 && d >= 1 && d <= mon[m - 1]) { d += ((y - 2013) * 12 + m - 1) * 31; a[d]++; r[d] = ""; for (int i = 0; i < 10; i++) r[d] += s[i + p]; } } int main() { cin >> s; for (int i = 0; i <= s.size() - 10; i++) tr(i); int ans = 0; for (int i = 0; i < 1500; i++) if (a[i] > a[ans]) ans = i; cout << r[ans]; }
#include <bits/stdc++.h> using namespace std; string s; string tmp; string ans; int mx; map<string, int> m; const int MD[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const bool flg[] = {0, 0, 1, 0, 0, 1, 0, 0, 0, 0}; bool check(int l, int r) { int g = 0, d = 0, m = 0, y = 0; for (int i = l; i <= r; i++) { if (s[i] == '-' && flg[i - l]) g++; else if (s[i] == '-' && !flg[i - l]) return false; } if (g != 2) { return false; } for (int i = l + 6; i <= l + 9; i++) { y = y * 10 + s[i] - '0'; } if (y > 2015 || y < 2013) { return false; } for (int i = l + 3; i <= l + 4; i++) { m = m * 10 + s[i] - '0'; } if (m <= 0 || m > 12) { return false; } for (int i = l; i <= l + 1; i++) { d = d * 10 + s[i] - '0'; } if (d <= 0 || d > MD[m]) { return false; } return true; } int main() { cin >> s; int l = 0, r = 9; int sz = s.size(); while (r <= sz) { tmp = ""; tmp = s.substr(l, 10); if (check(l, r)) { m[tmp]++; if (m[tmp] > mx) { mx = m[tmp]; ans = ""; ans = tmp; } } l++; r++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int a[200000]; int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; vector<string> b; int main() { string s, d; int i, j; cin >> s; int ma, k, da, m, y; for (i = 0; i < s.length(); i++) { if (s[i] == '-') a[i]++; if (i > 0) a[i] += a[i - 1]; } for (i = 0; i < s.length() - 9; i++) if (s[i + 2] == '-' && s[i + 5] == '-' && a[i + 9] - a[i - 1] == 2) { da = (s[i] - 48) * 10 + s[i + 1] - 48; m = (s[i + 3] - 48) * 10 + s[i + 4] - 48; y = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 + (s[i + 8] - 48) * 10 + (s[i + 9] - 48); if (1 <= m && m <= 12 && 1 <= da && da <= day[m] && 2013 <= y && y <= 2015) { for (d = "", j = 0; j <= 9; j++) d += s[i + j]; b.push_back(d); } } sort(b.begin(), b.end()); ma = 0, d = "", k = 0; for (i = 0; i < b.size(); i++) { if (i == 0 || b[i] == b[i - 1]) k++; else k = 1; if (k > ma) ma = k, d = b[i]; } cout << d; return 0; }
#include <bits/stdc++.h> using namespace std; char data[13], s[100006], sol[13]; int vmax, an, l, zi, val, maxi; int main() { cin >> s; maxi = 0; for (an = 2013; an <= 2015; an++) { for (l = 1; l <= 12; l++) { int vmax; if (l == 1 || l == 3 || l == 5 || l == 7 || l == 8 || l == 10 || l == 12) vmax = 31; else { if (l == 2) vmax = 28; else vmax = 30; } for (zi = 1; zi <= vmax; zi++) { if (zi < 10) { data[0] = '0'; data[1] = char('0' + zi); } else { data[0] = char(zi / 10 + '0'); data[1] = char(zi % 10 + '0'); } data[2] = '-'; if (l < 10) { data[3] = '0'; data[4] = char(l + '0'); } else { data[3] = char(l / 10 + '0'); data[4] = char(l % 10 + '0'); } data[5] = '-'; data[6] = char(an / 1000 + '0'); data[7] = char(an / 100 % 10 + '0'); data[8] = char(an / 10 % 10 + '0'); data[9] = char(an % 10 + '0'); val = 0; for (unsigned int i = 0; i < strlen(s) - 9; i++) { if (strncmp(s + i, data, 10) == 0) { val++; if (val > maxi) { maxi = val; strcpy(sol, data); } } } } } } cout << sol; return 0; }
#include <bits/stdc++.h> using namespace std; long long ans, res, p, q, x; int cnt[10]; void solve() { string str, st = "", st1 = "", st2 = "", m = ""; cin >> str; string s1 = "2013"; string s2 = "2014"; string s3 = "2015"; map<string, long long> mp; for (int i = 6; i < str.size() - 3; i++) { st = str.substr(i, 4); if (st == s1 || st == s2 || st == s3) { st1 = "", st2 = ""; if (str[i - 4] != '-') continue; if (str[i - 1] != '-') continue; st1 = st1 + str[i - 3] + str[i - 2]; st2 = st2 + str[i - 6] + str[i - 5]; if ((st1[0] >= '0' || st1[0] <= '9') && (st1[1] >= '0' && st1[1] <= '9')) { if ((st2[0] >= '0' && st2[0] <= '9') && (st2[1] >= '0' && st2[1] <= '9')) { if (st1 == "00" || st2 == "00") continue; if ((st1 == "04" || st1 == "6" || st1 == "09" || st1 == "11") && st2 <= "30") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } else if (st1 == "02" && st2 <= "28") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } else if ((st1 == "01" || st1 == "03" || st1 == "05" || st1 == "07" || st1 == "08" || st1 == "10" || st1 == "12") && st2 <= "31") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } } } } } for (auto it = mp.begin(); it != mp.end(); ++it) { ans = max(ans, it->second); } for (auto it = mp.begin(); it != mp.end(); ++it) { if (it->second == ans) { cout << it->first << "\n"; return; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt = 1; while (tt--) solve(); }
#include <bits/stdc++.h> using namespace std; int main() { vector<string> subs; int l; string a, b; cin >> a; l = a.size(); for (int i = 0; i < l - 9; ++i) { b = a.substr(i, 10); if ((b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') <= 28) && (((b[0] - '0') * 10 + b[1] - '0') > 0)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } else if ((((b[3] - '0') * 10 + b[4] - '0') != 2) && (b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') > 28) && (((b[0] - '0') * 10 + b[1] - '0') <= 30)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } else if ((((b[3] - '0') * 10 + b[4] - '0') != 11) && (((b[3] - '0') * 10 + b[4] - '0') != 9) && (((b[3] - '0') * 10 + b[4] - '0') != 6) && (((b[3] - '0') * 10 + b[4] - '0') != 4) && (((b[3] - '0') * 10 + b[4] - '0') != 2) && (b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') == 31)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } } l = subs.size(); sort(subs.begin(), subs.end()); subs.push_back(""); int cmax = -1; int ccur = 0; b = ""; for (int i = 0; i < l; ++i) { if (subs[i] == subs[i + 1]) { ccur++; } else { if (ccur > cmax) { cmax = ccur; b = subs[i]; } ccur = 0; } } cout << b << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; struct Node { int d, m, y; bool operator<(const Node &rhs) const { return d < rhs.d || (d == rhs.d && (m < rhs.m || (m == rhs.m && y < rhs.y))); } }; map<Node, int> cnt; char s[N]; int n; void check2(int i) { if (i + 9 >= n) return; if (!isdigit(s[i])) return; if (!isdigit(s[i + 1])) return; if (!isdigit(s[i + 3])) return; if (!isdigit(s[i + 4])) return; if (!isdigit(s[i + 6])) return; if (!isdigit(s[i + 7])) return; if (!isdigit(s[i + 8])) return; if (!isdigit(s[i + 9])) return; if (s[i + 2] != '-' || s[i + 5] != '-') return; int d = s[i] - '0'; d = d * 10 + (s[i + 1] - '0'); int m = s[i + 3] - '0'; m = m * 10 + (s[i + 4] - '0'); int y = s[i + 6] - '0'; y = y * 10 + (s[i + 7] - '0'); y = y * 10 + (s[i + 8] - '0'); y = y * 10 + (s[i + 9] - '0'); if (d < 1 || d > 31) return; if (m < 1 || m > 12) return; if (d > days[m]) return; if (y < 2013 || y > 2015) return; } void check(int i) { int d = 0, m = 0, y = 0; if (i + 2 >= n || s[i + 1] == '-' || s[i + 2] != '-') return; d = s[i++] - '0'; d = d * 10 + (s[i++] - '0'); if (i + 1 >= n || s[i + 1] == '-') return; i++; if (i + 2 >= n || s[i + 1] == '-' || s[i + 2] != '-') return; m = s[i++] - '0'; m = m * 10 + (s[i++] - '0'); if (i + 1 >= n || s[i + 1] == '-') return; i++; if (i + 3 >= n || s[i + 1] == '-' || s[i + 2] == '-' || s[i + 3] == '-') return; y = s[i++] - '0'; y = y * 10 + (s[i++] - '0'); y = y * 10 + (s[i++] - '0'); y = y * 10 + (s[i++] - '0'); if (d < 1 || d > 31) return; if (m < 1 || m > 12) return; if (d > days[m]) return; if (y < 2013 || y > 2015) return; cnt[Node{d, m, y}]++; } int main() { ios::sync_with_stdio(false); cin >> s; n = strlen(s); for (int i = 0; i < n; ++i) { if (s[i] != '-') check(i); } Node ans = {0, 0, 0}; int mx = 0; for (auto p : cnt) { if (p.second > mx) { mx = p.second; ans = p.first; } } if (ans.d < 10) cout << 0; cout << ans.d; cout << "-"; if (ans.m < 10) cout << 0; cout << ans.m; cout << "-"; cout << ans.y << '\n'; return 0; }
#include <bits/stdc++.h> char str[100100]; int a[20], f[60000]; int main() { int i, j, l, r, y, n, x, p, s, ans, h; memset(a, 0, sizeof(a)); a[4] = a[6] = a[9] = a[11] = 1; while (~scanf("%s", str)) { memset(f, 0, sizeof(f)); ans = 0; h = 0; l = strlen(str); for (i = 0; i <= l - 10; i++) { x = 1; for (j = 0; j <= 9; j++) { if ((j == 2) || (j == 5)) { if (str[i + j] != '-') x = 0; } else { if (str[i + j] == '-') x = 0; } } if (x) { p = 1; r = (str[i] - '0') * 10 + (str[i + 1] - '0'); y = (str[i + 3] - '0') * 10 + (str[i + 4] - '0'); n = (str[i + 6] - '0') * 1000 + (str[i + 7] - '0') * 100 + (str[i + 8] - '0') * 10 + (str[i + 9] - '0'); if (n < 2013 || n > 2015) p = 0; if ((y > 12) || (y < 1)) p = 0; if (y == 2) { if (r > 28) p = 0; } else if (a[y]) { if (r > 30) p = 0; } else { if (r > 31) p = 0; } if (r == 0) p = 0; if (p) { s = (n % 10) * 10000 + y * 100 + r; f[s]++; if (f[s] > h) { ans = s; h = f[s]; } if (f[s] == h && ans > s) ans = s; } } } x = ans % 100; ans /= 100; p = ans % 100; ans /= 100; if (x / 10 == 0) printf("0"); printf("%d-", x); if (p / 10 == 0) printf("0"); printf("%d-201%d\n", p, ans); } }
#include <bits/stdc++.h> using namespace std; int hash1(string s) { int n = 0, b = 1; for (int i = 0; i < s.size(); i++, b *= 10) n += s[i] * b; return n; } int main(int argc, char const *argv[]) { string str; cin >> str; int s; int i, j, k, t, p; string date; map<int, int> m; map<int, string> ref; for (i = 0; i < str.size(); i++) { s = 0; string made = ""; j = i - 1; while (1) { j++; if (s == 0) { if (str[j] >= '0' && str[j] <= '9') { s = 1; made.append(1, str[j]); continue; } else break; } if (s == 1) { if (str[j] >= '0' && str[j] <= '9') { s = 2; made.append(1, str[j]); continue; } else break; } if (s == 2) { if (str[j] == '-') { s = 3; made.append(1, str[j]); continue; } else break; } if (s == 3) { if (str[j] >= '0' && str[j] <= '9') { s = 4; made.append(1, str[j]); continue; } else break; } if (s == 4) { if (str[j] >= '0' && str[j] <= '9') { s = 5; made.append(1, str[j]); continue; } else break; } if (s == 5) { if (str[j] == '-') { s = 6; made.append(1, str[j]); continue; } else break; } if (s == 6) { if (str[j] >= '0' && str[j] <= '9') { s = 7; made.append(1, str[j]); continue; } else break; } if (s == 7) { if (str[j] >= '0' && str[j] <= '9') { s = 8; made.append(1, str[j]); continue; } else break; } if (s == 8) { if (str[j] >= '0' && str[j] <= '9') { s = 9; made.append(1, str[j]); continue; } else break; } if (s == 9) { if (str[j] >= '0' && str[j] <= '9') { s = 10; made.append(1, str[j]); continue; } else break; } if (s == 10) { string d = made.substr(0, 2); string mo = made.substr(3, 2); string y = made.substr(6, 4); int date, month, year; istringstream(d) >> date; istringstream(mo) >> month; istringstream(y) >> year; if (!(year >= 2013 && year <= 2015)) break; if (date <= 0) break; if (!(month >= 1 && month <= 12)) break; if (month == 2) { if (date > 28) break; } else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if (date > 31) break; } else { if (date > 30) break; } int h = hash1(made); ref[h] = made; if (m.find(h) == m.end()) m[h] = 1; else m[h] = m[h] + 1; break; } j++; } } map<int, int>::iterator it; int mx = 0; string maxs; for (it = m.begin(); it != m.end(); it++) { if (it->second > mx) { mx = it->second; maxs = ref[it->first]; } } cout << maxs << endl; ; return 0; }
#include <bits/stdc++.h> using namespace std; bool check(string s) { if (s.length() < 10) { return false; } if (s[2] != '-' || s[5] != '-') { return false; } if (s[6] != '2' || s[7] != '0' || s[8] != '1' || (s[9] != '3' && s[9] != '4' && s[9] != '5')) { return false; } if (s[0] < '0' || s[0] > '3') return false; if (s[1] < '0' || s[1] > '9') return false; if (s[3] < '0' || s[3] > '2') return false; if (s[4] < '0' || s[4] > '9') return false; long long d = (long long)(s[0] - '0') * 10 + (long long)(s[1] - '0'); long long m = (long long)(s[3] - '0') * 10 + (long long)(s[4] - '0'); if (m < 1 || m > 12) { return false; } if (m == 4 || m == 6 || m == 9 || m == 11) { if (d < 1 || d > 30) { return false; } } else if (m == 2) { if (d < 1 || d > 28) { return false; } } else { if (d < 1 || d > 31) { return false; } } return true; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; map<string, long long> mp; long long n = s.length(); for (long long i = 0; i < n; i++) { string s1 = s.substr(i, 10); if (check(s1)) { mp[s1]++; } } long long maxi = -1; string s2; for (auto j : mp) { if (j.second > maxi) { maxi = j.second; s2 = j.first; } } cout << s2 << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; char x[100100]; long x2[100100]; long mes[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; long wr = 0; long res, cur, repsmax = -1; long reps = 0; long tmp1, tmp2, tmp3; string s1; int compare(const void *a, const void *b) { return (*(long *)a - *(long *)b); } long check(long z) { if ((isdigit(x[z])) && (isdigit(x[z + 1])) && (isdigit(x[z + 3])) && (isdigit(x[z + 4])) && (isdigit(x[z + 6])) && (isdigit(x[z + 7])) && (isdigit(x[z + 8])) && (isdigit(x[z + 9]))) { if ((x[z + 2] == x[z + 5]) && (x[z + 2] == '-')) { tmp1 = ((long)(x[z]) - (long)('0')) * 10 + ((long)(x[z + 1]) - (long)('0')); tmp2 = ((long)(x[z + 3]) - (long)('0')) * 10 + ((long)(x[z + 4]) - (long)('0')); tmp3 = ((long)(x[z + 6]) - (long)('0')) * 1000 + ((long)(x[z + 7]) - (long)('0')) * 100 + (((long)(x[z + 8]) - (long)('0')) * 10) + ((long)(x[z + 9]) - (long)('0')); if ((tmp2 <= 12) && (tmp3 <= 2015) && (tmp3 >= 2013)) { if ((tmp1 <= mes[tmp2]) && (tmp2 != 0) && (tmp1 != 0)) { x2[wr++] = tmp1 + tmp2 * 100 + tmp3 * 10000; } } } } if ((!isdigit(x[z + 9])) && (x[z + 9] != '-')) { return -2; } } int main(int argc, char *argv[]) { scanf("%s", &x); long j = 0; while (check(j++) > -2) { } qsort(x2, wr - 1, sizeof(long), compare); cur = x2[0]; for (long j = 0; j < wr; j++) { if (cur == x2[j]) { reps++; } else { if (reps > repsmax) { repsmax = reps; res = cur; } cur = x2[j]; reps = 1; } } if (reps > repsmax) { repsmax = reps; res = cur; } cur = x2[j]; reps = 1; ldiv_t divresult1; divresult1 = ldiv(res, 100); if (divresult1.rem < 10) { cout << "0"; } cout << divresult1.rem << "-"; ldiv_t divresult2; divresult2 = ldiv(res, 10000); if (((divresult2.rem - divresult1.rem) / 100) < 10) { cout << "0"; } cout << (divresult2.rem - divresult1.rem) / 100 << "-"; ldiv_t divresult3; divresult3 = ldiv(res, 100000000); cout << (divresult3.rem - divresult2.rem) / 10000; return EXIT_SUCCESS; }
#include <bits/stdc++.h> using namespace std; map<string, int> f; int k[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool invalid(char a) { return a == '-'; } void calc(string s) { if (s[2] != '-' || s[5] != '-') return; for (int i = 0; i < s.length(); i++) if (i == 2 || i == 5) continue; else if (invalid(s[i])) return; string d = s.substr(0, 2), m = s.substr(3, 2), y = s.substr(6, 4); int year = atoi(y.c_str()), month = atoi(m.c_str()), day = atoi(d.c_str()); if (year < 2013 || year > 2015 || month < 1 || month > 12 || day < 1 || day > k[month]) return; f[s]++; } int main() { int maxi = -1; string s, MX = ""; cin >> s; for (int i = 0; i < s.size() - 9; i++) calc(s.substr(i, 10)); for (map<string, int>::iterator it = f.begin(); it != f.end(); it++) if (it->second > maxi) maxi = it->second, MX = it->first; cout << MX << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; char pro[M]; map<string, int> mp; int moon[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool OK(string a) { int len = a.length(); int year, month, day; year = (a[len - 4] - '0') * 1000 + (a[len - 3] - '0') * 100 + (a[len - 2] - '0') * 10 + (a[len - 1] - '0'); if (year > 2015 || year < 2013) { return false; } month = (a[len - 7] - '0') * 10 + (a[len - 6] - '0'); if (month < 1 || month > 12) { return false; } day = (a[len - 10] - '0') * 10 + (a[len - 9] - '0'); if (day < 1 || day > moon[month]) { return false; } return true; } bool judge(int i) { if (pro[i] != '-' && pro[i + 1] != '-' && pro[i + 2] == '-' && pro[i + 3] != '-' && pro[i + 4] != '-' && pro[i + 5] == '-' && pro[i + 6] != '-' && pro[i + 7] != '-' && pro[i + 8] != '-' && pro[i + 9] != '-') { return true; } return false; } int main() { scanf("%s", pro); int len = strlen(pro); for (int i = 0; i < len - 9; i++) { if (judge(i)) { char temp[15]; memcpy(temp, pro + i, 10); temp[10] = '\0'; mp[temp]++; } } map<string, int>::iterator k = mp.begin(); int num = 0; string ans; for (; k != mp.end(); k++) { if (num < (k->second) && OK(k->first)) { num = (k->second); ans = k->first; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string s; int arr[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; pair<int, int> f(int i) { if (i - 6 >= 0 && s[i - 4] == '-' && s[i - 1] == '-' && s[i - 3] >= '0' && s[i - 3] <= '9' && s[i - 2] >= '0' && s[i - 2] <= '9' && s[i - 6] >= '0' && s[i - 6] <= '9' && s[i - 5] >= '0' && s[i - 5] <= '9') { int x = (s[i - 3] - '0') * 10 + (s[i - 2] - '0'); if (x > 0 && x <= 12) { int d = (s[i - 6] - '0') * 10 + (s[i - 5] - '0'); if (d > 0 && d <= arr[x - 1]) return make_pair(d, x); } } return make_pair(-1, -1); } int main() { map<string, int> M; cin >> s; int v; int d = 0; string ans = ""; for (int i = 0; i < s.size(); i++) { if (i + 3 < s.size() && s[i] == '2' && s[i + 1] == '0' && s[i + 2] == '1' && (s[i + 3] >= '3' && s[i + 3] <= '5')) { pair<int, int> p = f(i); if (p.first != -1) { string a = ""; for (int j = i - 6; j < i + 4; j++) a += s[j]; if (M.count(a) == 0) { M[a] = 1; if (1 > d) { d = 1; ans = a; } } else { M[a]++; int t = M[a]; if (t > d) { d = t; ans = a; } } } } } cout << ans; return 0; }
#include <bits/stdc++.h> namespace patch { template <typename T> std::string to_string(const T& n) { std::ostringstream stm; stm << n; return stm.str(); } } // namespace patch using namespace std; long long int days[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, long long int> mp; bool chk(char a) { return (a >= '0' && a <= '9'); } void solve(string S) { if (S[2] == '-' && S[5] == S[2] && chk(S[0]) && chk(S[1]) && chk(S[3]) && chk(S[4]) && chk(S[6]) && chk(S[7]) && chk(S[8]) && chk(S[9])) { stringstream ss; ss << S; long long int D = 0, M = 0, Y = 0; ss >> D >> M >> Y; D = abs(D); M = abs(M); Y = abs(Y); if (D == 0 || D > 31 || M == 0 || M > 12 || Y < 2013 || Y > 2015) { return; } if (D > 0 && D <= days[M - 1]) { mp[S]++; } } } int main() { string S; cin >> S; for (int i = 0; i < S.size() - 9; i++) { string tmp = ""; for (int j = i; j < i + 10; j++) { tmp += S[j]; } solve(tmp); } long long int mx = 0; string tmp; for (auto it : mp) { if (mx < it.second) { mx = it.second; tmp = it.first; } } stringstream ss; long long int X; ss << tmp; ss >> X; X = abs(X); if (X < 10) { cout << 0; } cout << X << '-'; ss >> X; X = abs(X); if (X < 10) { cout << 0; } cout << X << '-'; ss >> X; cout << abs(X); return 0; }
#include <bits/stdc++.h> using namespace std; string in; map<string, int> m; int meses[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main(int argc, char *argv[]) { cin >> in; for (int i = 2; i < in.size() - 7; ++i) { if (in[i] == '-') { string date(in.c_str() + i - 2, 10); int contador = 0; for (int j = 0; j < date.size(); ++j) if (date[j] == '-') contador++; if (date[2] == '-' && date[5] == '-' && date[0] != '-' && contador == 2) { m[date]++; date.clear(); } } } int maior = -1; string in; for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it) { int day, month, year; sscanf((*it).first.c_str(), "%d-", &day); sscanf((*it).first.c_str() + 3, "%d-", &month); sscanf((*it).first.c_str() + 6, "%d", &year); if ((*it).second > maior && year >= 2013 && year <= 2015) if (day >= 1 && month >= 1 && month <= 12 && day <= meses[month - 1]) { maior = (*it).second; in = (*it).first; } } cout << in << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int k[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, int> f; string s; int main() { int i, j, n = 0, y, m, d; string t, x; cin >> s; for (i = 0; i + 10 <= (int)s.length(); i++) { x = s.substr(i, 10); if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4) continue; if (m > 12 || m < 1) continue; if (d > k[m] || d < 1) continue; if (y < 2013 || y > 2015) continue; if (n < ++f[x]) { n = f[x]; t = x; } } cout << t; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> void pp(T v) { for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it) cout << *it << ' '; cout << endl; } template <class T> void pp(T v, int n) { for (int i = 0; i < (int)n; i++) cout << v[i] << ' '; cout << endl; } template <class T> inline void chmax(T &a, const T b) { a = max(a, b); } template <class T> inline void chmin(T &a, const T b) { a = min(a, b); } const int INF = 1 << 28; const double EPS = 1.0e-9; static const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main(void) { int N; cin >> N; string line; cin >> line; int A = 0, F = 0, I = 0; for (int i = 0; i < (int)N; i++) { switch (line[i]) { case 'A': A++; break; case 'F': F++; break; case 'I': I++; break; } } int ans = 0; for (int i = 0; i < (int)N; i++) { if (line[i] == 'A' || line[i] == 'I') { int irem = I - (line[i] == 'I' ? 1 : 0); if (irem <= 0) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <class T> T maxm(T a, T b) { return a > b ? a : b; } template <class T> T minm(T a, T b) { return a < b ? a : b; } template <class T> T abs(T a) { return a > 0 ? a : (-1) * a; } template <class T> T sq(T a) { return a * a; } char s[200005]; int main() { int n, f = 0, in = 0, a = 0; char ch; scanf("%d", &n); getchar(); for (int i = 0; i < n; i++) { scanf("%c", &ch); if (ch == 'A') a++; else if (ch == 'F') f++; else in++; } if (in == 1) cout << 1; else if (in > 1) cout << 0; else if (in == 0) cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; const long double pi = 3.141592654; int main() { cin.tie(0); std::ios::sync_with_stdio(false); int n; cin >> n; string str; cin >> str; int A = 0, F = 0, k = 0; for (int i = 0; i < n; i++) { if (str[i] == 'A') A++; else if (str[i] == 'F') F++; else k++; } if (k == 0) cout << A << endl; else if (k == 1) cout << 1 << endl; else cout << 0 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, sum1 = 0, sum2 = 0; cin >> n; string str; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == 'A') { sum++; } else if (str[i] == 'I') { sum1++; } else { sum2++; } } if (sum && sum1 == 0) { cout << sum << endl; } else if ((sum1 == 1 && sum) || (sum1 == 1 && sum2)) { cout << sum1 << endl; } else { cout << 0 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int i = 0, A = 0; for (int j = 0; j < n; j++) { if (s[j] == 'I') i++; if (s[j] == 'A') A++; } if (i == 1) cout << 1 << "\n"; else if (i > 1) cout << 0 << "\n"; else if (i == 0) { cout << A << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n; cin >> n; string s; cin >> s; int in = std::count(s.begin(), s.end(), 'I'); int ans = 0; if (in <= 1) { int all = std::count(s.begin(), s.end(), 'A'); if (in == 0) ans = all; else ans = 1; } cout << ans; return 0; }
#include <bits/stdc++.h> int main() { int n, A = 0, I = 0, F = 0, ans = 0; char c[200001]; scanf("%d", &n); scanf("%s", c); for (int i = 0; i < n; i++) { if (c[i] == 'A') A++; else if (c[i] == 'I') I++; else if (c[i] == 'F') F++; } if (I == 0) ans = A; else if (I == 1) ans = 1; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long int count = 0, i, n, a[3] = {0}; string s; cin >> n >> s; for (i = 0; i < s.length(); i++) { if (s[i] == 'A') a[0]++; else if (s[i] == 'I') a[1]++; else a[2]++; } if (a[1] == 1) cout << "1" << endl; else if (a[1] == 0) cout << a[0] << endl; else cout << "0" << endl; return 0; }
#include <bits/stdc++.h> const int N = 100; using namespace std; map<char, int> mp; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { char ch; cin >> ch; mp[ch]++; } if (mp['I'] == 1) { cout << 1 << endl; } else if (mp['I'] >= 2) { cout << 0 << endl; } else { cout << mp['A'] << endl; } return 0; }
#include <bits/stdc++.h> int main() { long j, n, I, A, F; char aux; scanf("%li", &n); scanf("%c", &aux); A = I = F = 0; for (j = 1; j <= n; j++) { scanf("%c", &aux); if (aux == 'A') { A++; } if (aux == 'F') { F++; } if (aux == 'I') { I++; } } if (I == 1) { printf("1\n"); } else { if (I > 1) { printf("0\n"); } else { printf("%ld\n", A); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { if (false) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int n; cin >> n; int ni = 0; int na = 0; int nf = 0; for (int i = 0; i < n; i++) { char b; cin >> b; if (b == 'I') { ni++; } else if (b == 'A') { na++; } else if (b == 'F') { nf++; } else { cout << "wrong char" << endl; return -1; } } int ans; if (ni > 1) { ans = 0; } else if (ni == 1) { ans = 1; } else { ans = na; } cout << ans << endl; if (false) { fclose(stdin); fclose(stdout); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long int n; long int qtde_i, qtde_a; char ch; cin >> n; qtde_i = 0; qtde_a = 0; for (long int i = 0; i < n; i++) { cin >> ch; if (ch == 'I') { qtde_i += 1; } else if (ch == 'A') { qtde_a += 1; } } if (0) { cout << "MAIN : char lidos =" << n << endl; cout << "QTDE_I = " << qtde_i << endl; cout << "QTDE_A = " << qtde_a << endl; } if (qtde_i > 0) { if (qtde_i > 1) { cout << 0 << endl; } else { cout << 1 << endl; } } else { cout << qtde_a << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long int a[200005], b[200005]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, count = 0, count1 = 0; cin >> n; char c[200005]; for (long long int i = 0; i < n; i++) { cin >> c[i]; if (c[i] == 'I') count++; else if (c[i] == 'A') count1++; } cout << (count ? (count == 1 ? 1 : 0) : count1); }
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, i = 0; cin >> n; for (int j = 0; j < n; j++) { char c; cin >> c; if (c == 'A') a++; else if (c == 'I') i++; } if (i == 1) cout << 1; else if (i > 0) cout << 0; else if (i == 0) cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, i, F = 0, I = 0, A = 0; char c[200001]; cin >> a; for (i = 1; i <= a; i++) { cin >> c[i]; if (c[i] == 'I') { I++; } else if (c[i] == 'F') { F++; } else { A++; } } if (I == 1) { cout << 1; } else if (I > 1) { cout << 0; } else { cout << A; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long int n, i, a, f, in; char ch; cin >> n; a = 0; in = 0; f = 0; for (i = 0; i < n; i++) { cin >> ch; if (ch == 'A') a++; else if (ch == 'I') in++; else f++; } if (in == 1) cout << in; else if (in > 1) cout << 0; else { cout << (a); } return 0; }
#include <bits/stdc++.h> using namespace std; int n, al, in; char s[200010]; int main() { al = in = 0; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) if (s[i] == 'A') al++; else if (s[i] == 'I') in++; if (in == 0) printf("%d\n", al); else if (in == 1) printf("1\n"); else printf("0\n"); return 0; }
#include <bits/stdc++.h> using namespace std; char c; int n, a, i, j; int main() { scanf("%d\n", &n); for (int j = 1; j <= n; j++) { scanf("%c", &c); switch (c) { case 'A': a++; break; case 'I': i++; break; } } if (i) { if (i == 1) printf("1\n"); else printf("0\n"); } else { printf("%d\n", a); } return 0; }
#include <bits/stdc++.h> using namespace std; int cnt[26]; int main() { int n; scanf("%d", &n); string x; cin >> x; for (int i = 0; i < x.length(); i++) { cnt[x[i] - 'A']++; } int A = cnt[0], F = cnt['F' - 'A'], I = cnt['I' - 'A']; int cnt = 0; for (int i = 0; i < x.length(); i++) { if (x[i] != 'F') { int tmp = A + F; if (x[i] == 'A' || x[i] == 'F') tmp--; if (tmp == n - 1) cnt++; } } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> int main() { int a[3], i, n, k; char c; while (scanf("%d", &n) != EOF) { getchar(); memset(a, 0, sizeof(a)); k = 0; for (i = 0; i < n; i++) { scanf("%c", &c); if (c == 'A') a[0]++; if (c == 'F') a[1]++; if (c == 'I') a[2]++; } if (a[0] > 0 && a[2] == 0) k += a[0]; else if (a[2] == 1) k++; printf("%d\n", k); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200004; int main() { int n; char s[N]; map<char, int> mp; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) mp[s[i]]++; if (mp.count('I') > 0) { if (mp['I'] >= 2) puts("0"); else puts("1"); } else cout << count(s, s + n, 'A'); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int I = 0, F = 0, A = 0; for (auto ch : s) { if (ch == 'A') A += 1; else if (ch == 'I') I += 1; else F += 1; } if (I == 0) { cout << A << endl; return 0; } if (I > 0) { if (I == 1) cout << 1 << endl; else cout << 0 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T MAX(T a, T b) { if (a > b) return a; return b; } template <class T> inline T MIN(T a, T b) { if (a < b) return a; return b; } template <class T> inline T ABS(T x) { if (x < 0) return -x; return x; } inline void OPEN(const string &s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const static int inf = 1000000000; int n; char input[200005]; bool ada = false; int main() { scanf("%d", &n); scanf("%s", input); int a = 0, b = 0; for (int(i) = (0); (i) < (n); ++(i)) { if (input[i] == 'I') { a++; ada = true; } else if (input[i] == 'A') { b++; } } if (ada) { if (a == 1) printf("1\n"); else printf("0\n"); } else printf("%d\n", b); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n, m; while (cin >> n) { string st; cin >> st; long long cnt = 0; for (int i = 0; i < n; i++) { if (st[i] == 'I') cnt++; } if (cnt == 0) { for (int i = 0; i < n; i++) if (st[i] == 'A') cnt++; cout << cnt << endl; } else { if (cnt != 1) cnt = 0; cout << cnt << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long MD = 1000000007; long long md = 998244353; const long long INF = 1e18L + 5; long long exp(long long a, long long b) { long long r = 1ll; while (b > 0) { if (b & 1) { r = r * (a % md); r = (r + md) % md; } b /= 2; a = (a % md) * (a % md); a = (a + md) % md; } return (r + md) % md; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long pow_2(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a); a = (a * a); b >>= 1; } return res; } bool isPrime(long long a) { for (long long i = 3; (i * i) <= a; i += 2) { if ((a % i) == 0) return false; } if ((a != 2) && ((a % 2) == 0)) return false; if (a == 1) return false; return true; } string decToBinary(int n) { string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) s = s + "1"; else s = s + "0"; } return s; } int decimalToBinary(int N) { unsigned long long int B_Number = 0; int cnt = 0; while (N != 0) { int rem = N % 2; unsigned long long int c = pow(10, cnt); B_Number += rem * c; N /= 2; cnt++; } return B_Number; } string toString(unsigned long long int num) { std::string number; std::stringstream strstream; strstream << num; strstream >> number; return number; } const double PI = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; int a = 0, j = 0, f = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') a++; else if (s[i] == 'I') j++; else f++; } if (j >= 2) cout << "0" << endl; else { if (j == 1) cout << "1" << endl; else { cout << a << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, A = 0, F = 0, I = 0; char S[200005]; cin >> n; cin >> S; for (int i = 0; i < n; i++) { if (S[i] == 'A') A++; else if (S[i] == 'I') I++; } if (I == 0) { cout << A << endl; return 0; } if (I == 1) { cout << 1 << endl; return 0; } else cout << 0 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string s; cin >> s; int contA = 0, contI = 0, contF = 0; for (int i = 0; i < N; i++) { if (s[i] == 'A') contA++; if (s[i] == 'I') contI++; if (s[i] == 'F') contF++; } if (contI <= 1) { if (contI == 1) cout << 1 << endl; else cout << contA << endl; } else { cout << 0 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; char ch[200009]; int main() { int n; scanf("%d", &n); scanf("%s", ch); int a = 0, b = 0; for (int i = 0; i < n; i++) if (ch[i] == 'I') a++; for (int i = 0; i < n; i++) if (ch[i] == 'A') b++; if (a == 1) printf("%d\n", a); else if (a == 0) printf("%d\n", b); else printf("0\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; int sumA; int sumF; int sumI; while (cin >> n) { sumA = sumF = sumI = 0; cin >> s; for (int i = 0; i < n; ++i) { if (s[i] == 'A') sumA++; else if (s[i] == 'F') sumF++; else sumI++; } if (sumI == 0) cout << sumA << endl; else if (sumI == 1) cout << "1" << endl; else cout << "0" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n; cin >> n; string str; cin >> str; int cnti = 0, cnta = 0; for (int i = 0; i < ((int)(str).size()); i++) { cnti += str[i] == 'I'; cnta += str[i] == 'A'; } if (cnti > 1) cout << 0; else if (cnti == 1) cout << 1; else cout << cnta; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int countF = 0, countAI = 0, countIN = 0; int n; int show = 0; string game; cin >> n; cin >> game; for (int i = 0; i < n; i++) { if (game[i] == 'F') countF++; else if (game[i] == 'I') countIN++; else if (game[i] == 'A') countAI++; } if ((countIN == 0 && countAI == 0)) show = 0; else if (countIN == 0) show = countAI; else if ((countF != 0 && countIN == 1) || (countAI != 0 && countIN == 1)) show = countIN; cout << show; return 0; }
#include <bits/stdc++.h> using namespace std; double PI = 3.1415926536; int main() { long long n; cin >> n; string s; cin >> s; int a = 0, f = 0, I = 0; for (int i = 0; i < n; i++) { if (s[i] == 'F') f++; else if (s[i] == 'I') I++; else if (s[i] == 'A') a++; } if (a > 0 || f > 0) { if (I == 0) cout << a; else if (I == 1) { cout << 1; } else { cout << 0; } } else { cout << 0; } return 0; }
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s; cin >> s; long long int a = 0; long long int b = 0; long long int c = 0; for (long long int i = 0; i < s.size(); ++i) { if (s[i] == 'A') { a++; } if (s[i] == 'F') { b++; } if (s[i] == 'I') { c++; } } if (c == 0) { cout << a << "\n"; ; return 0; } if (c == 1) { cout << 1 << "\n"; ; return 0; } cout << 0 << "\n"; ; }
#include <bits/stdc++.h> using namespace std; int main() { char s; int i, j, n, all, in, fold, c, d; all = 0; in = 0; fold = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> s; if (s == 'A') all++; if (s == 'I') in++; if (s == 'F') fold++; } if (in == 0) cout << all; else if (in == 1) cout << 1; else cout << 0; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, r = 0; char s[200000]; cin >> n >> s; int a = 0, f = 0, i = 0; for (int j = 0; j < n; ++j) { if (s[j] == 'A') ++a; else if (s[j] == 'F') ++f; else if (s[j] == 'I') ++i; } if (i > 0) { cout << (i == 1 ? 1 : 0) << endl; } else { cout << (n - f) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, l, a[4] = {}, cnt = 0, maxi = 0; string s; cin >> n >> s; l = s.length(); for (i = 0; i < l; i++) { if (s[i] == 'A') { a[1]++; } else if (s[i] == 'F') { a[2]++; } else if (s[i] == 'I') { a[3]++; } } if (a[3] >= 2) { cout << "0\n"; } else if (a[3] == 1) { cout << "1\n"; return 0; } else { cout << a[1]; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; int a[MAX]; int main() { int n; cin >> n; string s; cin >> s; int a1 = 0, a2 = 0, a3 = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') { a1++; } else if (s[i] == 'I') { a2++; } else { a3++; } } if (a2 == 0) { cout << a1 << endl; } else { if (a2 == 1) { cout << 1 << endl; } else { cout << 0 << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n, A(0), I(0); string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == 'A') { A++; } else if (s[i] == 'I') { I++; } } if (I == 0) { cout << A << endl; } if (I == 1) { cout << I << endl; } else if (I > 1) { cout << 0 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) { if (s[i] == 'I') cnt++; } if (cnt == 0) { for (int i = 0; i < n; i++) if (s[i] == 'A') cnt++; cout << cnt; } else if (cnt == 1) { cout << 1; } else { cout << 0; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d\n", &n); char tmp; int cnt_A = 0; int cnt_I = 0; for (int i = 0; i < n; i++) { scanf("%c", &tmp); if (tmp == 'A') cnt_A++; if (tmp == 'I') cnt_I++; } if (cnt_I == 0) printf("%d\n", cnt_A); else { if (cnt_I > 1) printf("%d\n", 0); else printf("%d\n", cnt_I); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int f, i, a; for (int m = f = i = a = 0; s[m]; ++m) { if (s[m] == 'A') ++a; else if (s[m] == 'I') ++i; else ++f; } if (i > 1) cout << 0; else if (i == 1) cout << 1; else cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; int mas[30]; int main() { int n; scanf("%d", &n); string s; cin >> s; int a = 0, b = 0, c = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') ++a; if (s[i] == 'I') ++b; if (s[i] == 'F') ++c; } int cnt = 0; if (b == 1 && (a > 0 || c > 0)) cnt += b; if (b == 0 && (c > 0 || a > 1)) cnt += a; printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int i, cnt1 = 0, cnt2 = 0, cnt3 = 0; for (i = 0; i < s.length(); i++) { if (s[i] == 'A') cnt1++; else if (s[i] == 'F') cnt2++; else cnt3++; } if (cnt3 > 1 || cnt2 == n) cout << "0" << endl; else if (cnt3 == 1) cout << "1" << endl; else cout << cnt1 << endl; }
#include <bits/stdc++.h> int main() { int n, af(0), r(0); char s[200002]; std::scanf("%d\n", &n); std::fgets(s, sizeof(s), stdin); for (int i(0); i < n; ++i) af += (s[i] == 'A') || (s[i] == 'F'); for (int i(0); i < n; ++i) r += (s[i] != 'F') & (n == af + (s[i] == 'I')); std::printf("%d\n", r); return 0; }
#include <bits/stdc++.h> char array[200005]; int main() { long i, j, k, l, m, n, a, f; scanf("%ld", &n); scanf("%s", array); i = 0; a = 0; f = 0; for (j = 0; j < n; j++) { if (array[j] == 'A') a++; else if (array[j] == 'I') i++; else f++; } if (i > 1) { printf("0\n"); } else if (i == 1) { printf("1\n"); } else { printf("%ld\n", a); } return 0; }
#include <bits/stdc++.h> using namespace std; long long const INF = (long long)1e9; long long const INF64 = (long long)4e18; long long const v10e5 = (long long)100000; long long const v10e6 = (long long)1000000; long long const v10e9 = (long long)1000000000; long long const s10e5 = (long long)100000 + 10; long long const s10e6 = (long long)1000000 + 10; long long const s10e9 = (long long)1000000000 + 10; long long __dummy__; int main() { ios_base::sync_with_stdio(0); long long n; string s; cin >> n; cin >> s; long long a[3]; a[0] = 0; a[1] = 0; a[2] = 0; for (long long(i) = (0); (i) <= (n - 1); ++i) { if (s[i] == 'A') { a[0]++; } else if (s[i] == 'I') { a[1]++; } else { a[2]++; } } long long ans = 0; for (long long(i) = (0); (i) <= (n - 1); ++i) { int shift = 0; if (s[i] == 'A' || s[i] == 'I') { if (s[i] == 'I') shift = 1; if (a[1] - shift == 0) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int countI = 0, countA = 0, countF = 0; int n; char c; string s = ""; cin >> n; for (int i = 0; i < n; i++) { cin >> c; s += c; } for (int j = 0; j < s.length(); j++) { if (s.at(j) == 'I') countI++; else if (s.at(j) == 'A') countA++; else countF++; } if (countI == 1) cout << countI; else if (countI > 1) cout << "0"; else if (countI == 0) cout << countA; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int length, a = 0, i = 0; string status; cin >> length >> status; for (int x = 0; x < length; x++) { if (status[x] == 'A') { a++; } else if (status[x] == 'I') { i++; } } if (i == 0) { cout << a; } else { if (i == 1) { cout << 1; } else { cout << 0; } } return 0; }
#include <bits/stdc++.h> int main(void) { int n, i, q[] = {0, 0, 0}, ans = 0; char s[200001]; scanf("%d", &n); scanf("%s", s); for (i = 0; i < n; i++) { if (s[i] == 'A') q[0]++; else if (s[i] == 'I') q[1]++; else q[2]++; } if (q[1] == 0) ans = q[0]; else if (q[1] == 1) ans = 1; else ans = 0; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, x = 0, y = 0; string a; cin >> n >> a; for (int i = 0; i < n; i++) { if (a[i] == 'I') { x++; if (x == 2) { cout << "0"; return 0; } } else if (a[i] == 'A') { y++; } } if (x == 1) { cout << "1"; } else cout << y; return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long n; scanf("%I64d", &n); char stringinput[n + 1]; long long countI = 0; long long countA = 0; long long countF = 0; bool flag = true; scanf("%s", &stringinput); for (long long i = 0; i < n; i++) { if (stringinput[i] == 'I') { flag = false; countI++; } } if (flag == true) { for (long long j = 0; j < n; j++) { if (stringinput[j] == 'A') countA++; } } if (countI > 0) { if (countI == 1) printf("%I64d", countI); else printf("%I64d", countA); } else printf("%I64d", countA); return 0; }
#include <bits/stdc++.h> using namespace std; int b[200]; int main() { int n; cin >> n; string s; cin >> s; for (int i = 0; i < s.size(); i++) { b[s[i]]++; } int i = 'I', f = 'F', a = 'A'; if (!b[i]) { cout << b[a] << endl; } else if (b[i] == 1) { cout << 1 << endl; } else { cout << 0 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int players; cin >> players; int probably = 0; int prob_not = 0; for (int i = 0; i < players; i++) { char status; cin >> status; if (status == 'I') prob_not++; if (status != 'F') probably++; } if (prob_not == 1 && probably > 1) cout << 1 << endl; else if (prob_not > 1) cout << 0 << endl; else cout << probably << endl; cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; char x[1000000]; cin >> n; int a = 0, b = 0; for (int i = 0; i < n; i++) { cin >> x[i]; if (x[i] == 'I') { a++; } else if (x[i] == 'A') { b++; } } if (a == 0) { cout << b; } if (a == 1) { cout << 1; } if (a >= 2) { cout << 0; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[200500]; int main() { int n; scanf("%d", &n); char c; int res = 0; int A = 0; int F = 0; int I = 0; scanf("\n"); for (int i = 0; i < n; i++) { scanf("%c", &c); if (c == 'A') { A++; } if (c == 'F') { F++; } if (c == 'I') { I++; } } if (I == 0) { res = A; } if (I == 1) { res = 1; } if (I > 1) { res = 0; } printf("%d", res); }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int A = 0, I = 0, F = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') A++; else if (s[i] == 'I') I++; else F++; } if (!I) cout << A; else if (I == 1) cout << 1; else cout << 0; return 0; }
#include <bits/stdc++.h> using namespace std; const long long int mod = (1ll << 32); int main() { int N; string s; cin >> N; cin >> s; int F = count(s.begin(), s.end(), 'F'); int A = count(s.begin(), s.end(), 'A'); int I = count(s.begin(), s.end(), 'I'); if (I == 1) { cout << 1 << endl; return 0; } else if (I >= 2) { cout << "0" << endl; return 0; } else { cout << A << endl; return 0; } return 0; }
#include <bits/stdc++.h> char s[200005]; int main() { int N; while (scanf("%d", &N) == 1) { scanf("%s", s); int n = 0, a = 0, f = 0; for (int i = 0; i < N; ++i) { if (s[i] == 'I') n++; if (s[i] == 'A') a++; if (s[i] == 'F') f++; } if (n >= 2) { puts("0"); } else if (n == 1) { puts("1"); } else if (f == 0) { printf("%d\n", N); } else printf("%d\n", a); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int f = 0, a = 0, ii = 0; for (int j = 0; j < s.size(); j++) { if (s[j] == 'F') { f = 1; } else if (s[j] == 'A') { a++; } else { ii++; } } int res = 0; if (ii == 0) { for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') res++; } } else if (ii > 1) { res = 0; } else if (ii == 1) { res = 1; } cout << res; }
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, l = 0; string s; bool tI = 1; cin >> n >> s; for (int i = 0; i < ((int)s.size()); i++) { if (s[i] == 'A' && tI == 1) { ans++; } if (s[i] == 'I') { tI = 0; ans = 1; l++; } } if (l > 1) ans = 0; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, c[2 * 100000 + 10], num[3]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i < n + 1; ++i) { char t; cin >> t; if (t == 'A') { c[i] = 0; num[0]++; } else if (t == 'I') { c[i] = 1; num[1]++; } else { c[i] = 2; num[2]++; } } int ans = 0; for (int i = 1; i < n + 1; ++i) { if (c[i] == 2) continue; int t[3] = {num[0], num[1], num[2]}; t[c[i]]--; if (!t[1]) ++ans; } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; std::string int2str(int n) { std::ostringstream result; result << n; return result.str(); } int str2int(const std::string& s) { int result; std::istringstream ss(s); ss >> result; if (!ss) throw std::invalid_argument("StrToInt"); return result; } int main() { int N; cin >> N; int in = 0, allin = 0, folded = 0; for (int i = 0; i < (N); ++i) { char c; cin >> c; if (c == 'A') allin++; else if (c == 'I') in++; else folded++; } int res; if (in == 1) { res = 1; } else if (in == 0) { res = allin; } else { res = 0; } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> int main(void) { int N; scanf("%i", &N); int A = 0; int F = 0; int I = 0; char c; int i; scanf("%c", &c); for (i = 0; i < N; i++) { scanf("%c", &c); if (c == 'A') A++; else if (c == 'F') F++; else if (c == 'I') I++; } if (I == 0) { printf("%i\n", A); return 0; } if (I == 1) { printf("1\n"); return 0; } printf("0\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; while (cin >> n >> s) { int I = 0, A = 0, F = 0; int len = s.size(); for (int i = 0; i < len; i++) { if (s[i] == 'A') A++; else if (s[i] == 'F') F++; else I++; } if (I >= 2) { cout << 0 << endl; continue; } else if (I == 1) { cout << 1 << endl; continue; } else { cout << A << endl; continue; } } return 0; }
#include <bits/stdc++.h> using namespace std; int ts, kk = 1; long long MOD; template <class T> inline T _abs(T n) { return (n < 0 ? -n : n); } template <class T> inline T _max(T a, T b) { return (a > b ? a : b); } template <class T> inline T _min(T a, T b) { return (a < b ? a : b); } template <class T> inline T _sq(T x) { return x * x; } template <class T> inline T _sqrt(T x) { return (T)sqrt((double)x); } template <class T> inline T _pow(T x, T y) { T z = 1; for (int i = 1; i <= y; i++) { z *= x; } return z; } template <class T> inline T _gcd(T a, T b) { a = _abs(a); b = _abs(b); if (!b) return a; return _gcd(b, a % b); } template <class T> inline T _lcm(T a, T b) { a = _abs(a); b = _abs(b); return (a / _gcd(a, b)) * b; } template <class T> inline T _extended(T a, T b, T &x, T &y) { a = _abs(a); b = _abs(b); T g, x1, y1; if (!b) { x = 1; y = 0; g = a; return g; } g = _extended(b, a % b, x1, y1); x = y1; y = x1 - (a / b) * y1; return g; } template <class T> inline T getbit(T x, T i) { T t = 1; return (x & (t << i)); } template <class T> inline T setbit(T x, T i) { T t = 1; return (x | (t << i)); } template <class T> inline T resetbit(T x, T i) { T t = 1; return (x & (~(t << i))); } template <class T> inline T _bigmod(T n, T m) { T ans = 1, mult = n % MOD; while (m) { if (m & 1) ans = (ans * mult) % MOD; m >>= 1; mult = (mult * mult) % MOD; } ans %= MOD; return ans; } template <class T> inline T _modinv(T x) { return _bigmod(x, (T)(MOD - 2)) % MOD; } int num[500]; int main() { string s; int sl; cin >> sl >> s; for (int i = 0; i <= sl - 1; i++) { num[s[i]]++; } int ans = 0; for (int i = 0; i <= sl - 1; i++) { if (s[i] == 'F') continue; int tot = num['A'] + num['F']; if (s[i] == 'A') tot--; if (tot == sl - 1) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char s; int I = 0, A = 0; for (int i = 0; i < n; i++) { cin >> s; if (s == 'I') I++; if (s == 'A') A++; } if (I == 0) { cout << A; } if (I == 1) { cout << 1; } if (I > 1) { cout << 0; } return 0; }
#include <bits/stdc++.h> using namespace std; char s[300005]; int main(int argc, char* argv[]) { std::ios::sync_with_stdio(false); int n; scanf("%d", &n); scanf("%s", s); int num_i = 0, num_a = 0; bool flag_i = false; for (int i = 0; i < n; i++) { if (s[i] == 'I') { flag_i = true; num_i++; } if (s[i] == 'A') num_a++; } if (flag_i) { if (num_i > 1) num_i = 0; printf("%d\n", num_i); } else printf("%d\n", num_a); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int ic = 0, ac = 0; for (int i = 0; i < n; i++) { if (s[i] == 'I') { ic++; } else { if (s[i] == 'A') { ac++; } } } if (ic >= 2) { cout << 0 << endl; return 0; } else if (ic == 1) { cout << 1 << endl; return 0; } else { cout << ac << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<char> v; long long ca = 0, ci = 0, cf = 0; for (long long i = 0; i < n; i++) { char a; cin >> a; v.push_back(a); if (a == 'A') ca++; if (a == 'I') ci++; if (a == 'F') cf++; } if (ca + cf == n) cout << ca; else { if (ci > 1) cout << 0; else cout << ci; } for (long long i = 1; i < n; i++) { } }
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int I = count(s.begin(), s.end(), 'I'); if (I > 0) { if (I == 1) cout << I << endl; else cout << 0 << endl; } else { cout << count(s.begin(), s.end(), 'A') << endl; ; } } int main() { ios::sync_with_stdio(0); cin.tie(0); { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int ara[3], i, n; char ch; cin >> n; ara[0] = ara[1] = ara[2] = 0; for (i = 0; i < n; i++) { cin >> ch; if (ch == 'A') ara[0]++; else if (ch == 'I') ara[1]++; else ara[2]++; } if (ara[1] > 1) { cout << 0 << endl; } else if (ara[1]) { cout << 1 << endl; } else { cout << ara[0] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int A, I, F; int main() { int n, m, i, j, k, sum; int x, y; int tc, t; string str; cin >> n >> str; for (i = 0; i < n; i++) { if (str[i] == 'A') A++; else if (str[i] == 'I') I++; else F++; } if (I == 0) cout << A; else if (I == 1) cout << 1; else cout << 0; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000000000LL; const int inf = 0x3f3f3f3f; const long double EPS = 1e-9; long long n, m; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; map<char, long long> maps; int test = 1, tc = 1; while (test--) { cin >> n >> s; for (int i = 0; i < s.size(); i++) maps[s[i]]++; if (maps['I'] == 1) cout << "1" << endl; else if (maps['I'] > 1) cout << "0" << endl; else cout << maps['A'] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = (int)(INT_MAX - 100); const int N = (int)(0); const long long mod = (int)(1e+9 + 7); int c[3]; int main() { int n; cin >> n; string s; cin >> s; for (int v = 0; v < n; v++) { if (s[v] == 'F') c[2]++; else c[(s[v] == 'I')]++; } int k = 0; for (int v = 0; v < n; v++) if (s[v] != 'F') if (c[1] - (s[v] == 'I') == 0) k++; printf("%d\n", k); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; int a = 0, f = 0, i = 0; for (int j = 0; j < n; j++) { if (s[j] == 'A') ++a; if (s[j] == 'F') ++f; if (s[j] == 'I') ++i; } if (i == 1) cout << 1 << '\n'; if (i == 0) cout << a << '\n'; if (i > 1) cout << 0 << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t; cin >> t; string s; cin >> s; int countA = 0; int countI = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') { countA++; } else if (s[i] == 'I') { countI++; } } if (countI == 0) { cout << countA << endl; } else { if (countI == 1) { cout << 1 << endl; } else { cout << 0 << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, cnt = 0; cin >> n; char a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i] == 'A') { ans++; } if (a[i] == 'I') { cnt++; } } if (cnt == 0) { cout << ans; } else if (cnt == 1) { cout << 1; } else { cout << 0; } return 0; }