From 86599c4c0ca9f92919be631ed0db10d797afde83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Ng=E1=BB=8Dc=20Ph=C3=BA=20T=E1=BB=B7?= <148174474+tynnp@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:38:53 +0700 Subject: [PATCH] =?UTF-8?q?X=C3=A2u=20Con?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UPCODER/Other/XAUCON.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 UPCODER/Other/XAUCON.cpp diff --git a/UPCODER/Other/XAUCON.cpp b/UPCODER/Other/XAUCON.cpp new file mode 100644 index 0000000..d84caac --- /dev/null +++ b/UPCODER/Other/XAUCON.cpp @@ -0,0 +1,54 @@ +#include +#include +#include + +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 using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; +template using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>; + +const int MAXN = 1e6 + 5; +const int MOD = 1e9 + 7; + +int idx, len; +string s; +map 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; +} \ No newline at end of file