제출 #98415

#제출 시각아이디문제언어결과실행 시간메모리
98415ahmad_salahMiners (IOI07_miners)C++14
25 / 100
33 ms716 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, ans = 0; string s, m1 = "", m2 = ""; cin >> n >> s; for (int i = 0; i < n; i++) { set<char> s1, s2; if (m1.size() >= 2) s1.insert(m1[m1.size() - 2]); if (m1.size()) s1.insert(m1.back()); s1.insert(s[i]); if (m2.size() >= 2) s2.insert(m2[m2.size() - 2]); if (m2.size()) s2.insert(m2.back()); s2.insert(s[i]); if (i == n - 1) { if (m1.empty()) { m1 += s[i], ans += s1.size(); break; } if (m2.empty()) { m2 += s[i], ans += s2.size(); break; } } ans += max(s1.size(), s2.size()); if (s1.size() > s2.size()) m1 += s[i]; else if (s2.size() > s1.size()) m2 += s[i]; else m1.size() < m2.size() ? m1 += s[i] : m2 += s[i]; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...