제출 #534169

#제출 시각아이디문제언어결과실행 시간메모리
534169andecaandeciMiners (IOI07_miners)C++17
16 / 100
6 ms780 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; #pragma GCC optimize("Ofast") #define vi vector<int> #define vll vector<ll> #define pii pair<int, int> #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define sc second #define endl '\n' #define gl ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string s, s1 = "", s2 = ""; map<char, int> m1, m2; int ans = 0; map<char, int>::iterator it; int main() { cin >> n >> s; for(int i = 0; i < n; i++){ if(m1[s[i]] == 0 or m1[s[i]] <= m2[s[i]]){ m1[s[i]]++; s1 += s[i]; for(it = m1.begin(); it != m1.end(); ++it) if(it -> sc > 0) ans++; if(s1.size() > 2) m1[s1[s1.size() - 3]]--; } else{ m2[s[i]]++; s2 += s[i]; for(it = m2.begin(); it != m2.end(); ++it) if(it -> sc > 0) ans++; if(s2.size() > 2) m2[s2[s2.size() - 3]]--; } } cout << ans << endl; }
#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...