이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |