Skip to content

Commit

Permalink
Xâu Con
Browse files Browse the repository at this point in the history
  • Loading branch information
tynnp authored Dec 3, 2024
1 parent ce2626b commit 86599c4
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions UPCODER/Other/XAUCON.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'
#define int long long
#define inp freopen("file.inp", "r", stdin)
#define out freopen("file.out", "w", stdout)
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = 1e6 + 5;
const int MOD = 1e9 + 7;

int idx, len;
string s;
map<char, int> m;

signed main() {
fastIO;
cin >> s;

for (char &c : s)
c = tolower(c);

int i = 1, j = 1, k = 0;
int n = s.size();
s = ' ' + s;

while (i <= n && j <= n) {
k++;
m[s[j]]++;

while (m[s[j]] > 1) {
k--;
m[s[i++]]--;
}

if (k > len) {
idx = i;
len = k;
}

j++;
}

cout << idx << ' ' << len;
return 0;
}

0 comments on commit 86599c4

Please sign in to comment.