Submission #534474

#TimeUsernameProblemLanguageResultExecution timeMemory
534474christinelynnMiners (IOI07_miners)C++17
16 / 100
359 ms800 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll check(vector<char>v){ int n = v.size() - 1; bool M, B, F; M = B = F = 0; for(int i = 0; i < 3; i++){ if(v[n - i] == 'M') M = true; else if(v[n - i] == 'B') B = true; else if(v[n - i] == 'F') F = true; } return (M + B + F); } int main(){ int n; cin >> n; ll ans = 0; vector<char>s(n); for(int i = 1; i <= n; i++) cin >> s[i]; vector<char>a, b; a.push_back('A'); a.push_back('A'); b.push_back('A'); b.push_back('A'); for(int i = 1; i <= n; i++){ bool x, y; x = y = false; if(s[i] != a.back() && s[i] == b.back()){ a.push_back(s[i]); x = true; } else if(s[i] != b.back() && s[i] == a.back()){ b.push_back(s[i]); y = true; } else if(s[i] != a.back() && s[i] != b.back()){ auto it1 = find(s.begin() + i, s.end(), a.back()) - s.begin(); auto it2 = find(s.begin() + i, s.end(), b.back()) - s.begin(); if(it1 < it2){ a.push_back(s[i]); x = true; } else{ b.push_back(s[i]); y = true; } } else{ vector<char>tmpa, tmpb; tmpa = a; tmpb = b; tmpa.push_back(s[i]); tmpb.push_back(s[i]); if(check(tmpa) > check(tmpb)){ a.push_back(s[i]); x = true; } else{ b.push_back(s[i]); y = true; } } if(x) ans += check(a); else ans += check(b); } cout << ans << endl; 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...