text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; for (int i = 0; i < s.length() - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; for (int i = 1; i < int(s.size()); ++i) { if (s[i] < s[i - 1]) { cout << "YES" << endl; cout << i << " " << i + 1 << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int N, LST[26]; char S[300005]; int main() { scanf("%d", &N); scanf("%s", S); for (int i = 0; i < 26; i++) LST[i] = -1; for (int i = 0; i < N; i++) { LST[S[i] - 'a'] = i; for (int j = S[i] - 'a' + 1; j < 26; j++) { if (LST[j] != -1) { printf("YES\n%d %d\n", LST[j] + 1, i + 1); return 0; } } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int pos = -1; for (int i = 0; i < n - 1; ++i) { if (s[i] > s[i + 1]) { pos = i; break; } } if (pos != -1) { cout << "YES" << endl; cout << pos + 1 << ' ' << pos + 2 << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int len; string s; cin >> len >> s; int flag = 1; for (int i = 1; i < s.length(); i++) { if (s[i] < s[i - 1]) { cout << "YES" << endl; cout << i << " " << i + 1 << endl; flag = 0; break; } } if (flag) cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; cin >> n; cin >> str; for (int i = 0; i < n - 1; i++) { if (str[i] > str[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2 << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int a = 0, b = 0; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { a = i + 1; b = i + 2; break; } } if (a == 0 && b == 0) { cout << "NO" << endl; } else { cout << "YES" << endl; cout << a << " " << b << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { while (b) { long long int x = a % b; a = b; b = x; } return a; } long long int lcm(long long int a, long long int b) { return a / gcd(a, b) * b; } bool isPrime(long long int n) { if (n <= 1) return false; for (long long int i = 2; i <= sqrt(n); i++) if (n % i == 0) return false; return true; } int setbit(int n) { int c; while (n) { c += n & 1; n >>= 1; } return c; } bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } const int N = 300050; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tt = 1; while (tt--) { int n; string s; cin >> n >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << "\n"; cout << i + 1 << " " << i + 2 << "\n"; return 0; } } cout << "NO"; } }
#include <bits/stdc++.h> using namespace std; int n; string s; vector<pair<char, int>> t; void ReadInput() { cin >> n; t.resize(n); cin >> s; for (int i = 0; i < n; i++) t[i] = {s[i], i}; } void Solve() { sort(t.begin(), t.end()); for (int i = 1; i < n; i++) if (t[i].first != t[i - 1].first && t[i].second < t[i - 1].second) { cout << "YES\n"; cout << t[i].second + 1 << ' ' << t[i - 1].second + 1; return; } cout << "NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ReadInput(); Solve(); }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void solve() { int n; cin >> n; string s; cin >> s; vector<vector<int> > v(26); for (int i = 0; i < n; i++) { char a = s[i]; char k = a; k++; for (char j = k; j <= 'z'; j++) { int x = j - 'a'; if (v[x].size() > 0) { cout << "YES" << endl; cout << v[x].back() + 1 << " " << i + 1 << endl; return; } } v[a - 'a'].push_back(i); } cout << "NO" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tests = 1; while (tests--) { solve(); } }
#include <bits/stdc++.h> using namespace std; long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p = 0, q = 0, r, s, t, u, v, w, x, y, z, temp = 0, ans = 0, t1, t2, sum = 0; vector<long long int> v1, v2, v3, v4, v5, v6; vector<string> vs1, vs2, vs3, vs4; double f1, f2 = 0, f3, f4; vector<double> v10; vector<pair<long long int, long long int>> v11, v12, v13, v14; string s1, s2, s3, s4, s5, s6; long long int a10[100][3]; long long int a1[100000], a2[100000]; char c1, c2, c3; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s1; s2 = s1; sort(s2.begin(), s2.end()); if (s2 == s1) { cout << "NO"; return 0; } cout << "YES" << endl; j = n - 1; s2 = s1; reverse(s2.begin(), s2.end()); if (s1 == s2) { for (i = 0; i < n; i++) { if (s1[i] > s1[j]) { cout << i + 1 << " " << j + 1; return 0; } } } else { for (i = 0; i < n - 1; i++) { if (s1[i] > s1[i + 1]) { cout << i + 1 << " " << i + 2; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; const int mxn = 105; int arr[mxn]; string s; int n; void solve() { int a = 0, b = 0; char curr = s[0]; for (int i = 1; i < s.size(); i++) { if (curr <= s[i]) { curr = s[i]; a = i; } else { b = i; break; } } if (b) { cout << "YES" << '\n' << a + 1 << " " << b + 1; } else { cout << "NO" << '\n'; } } void read() { cin >> n >> s; } int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int T = 1; while (T--) read(), solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; bool b = true; for (int i = 1; i < n; i++) if (s[i] < s[i - 1]) b = false; if (b) { cout << "NO"; return 0; } cout << "YES" << endl; for (int i = 1; i < n; i++) if (s[i] < s[i - 1]) { cout << i << " " << i + 1; return 0; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 3e5 + 10; char str[N]; int main() { int len; scanf("%d", &len); scanf("%s", str); int maxx = str[0], flag = 0, l = 0, r; for (int i = 1; i < len; i++) { if (str[i] < maxx) { r = i; flag = 1; break; } else { maxx = str[i]; l = i; } } if (flag) printf("YES\n%d %d\n", l + 1, r + 1); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; for (int i = 0; i < s.size() - 1; i++) { if (s[i + 1] < s[i]) { cout << "YES" << endl; cout << i + 1 << " " << i + 1 + 1 << endl; exit(0); } } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int a; cin >> a >> s; for (int k = 0; k < s.size() - 1; k++) { if (s[k] > s[k + 1]) { cout << "YES" << endl << k + 1 << " " << k + 2; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; long long ind = 0; while (ind < n - 1) { if (s[ind] > s[ind + 1]) { break; } ind++; } if (ind >= n - 1) { cout << "NO"; return 0; } cout << "YES\n"; cout << ind + 1 << " " << ind + 2; return 0; }
#include <bits/stdc++.h> using namespace std; string s; int n; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15); cin >> n >> s; for (int i = (0); i <= (((int)(s).size() - 1) - 1); i += (+1)) { if (s[i] > s[i + 1]) { cout << "YES\n"; cout << i + 1 << ' ' << i + 2 << '\n'; return 0; } } cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, i, flag = 0; cin >> n >> s; for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2 << endl; return 0; } } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, i, x = 0, c = 0; string s; cin >> n >> s; for (i = 0; i < s.size() - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2 << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long int n, i; cin >> n; string s; cin >> s; long int flag = 0; for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { char temp; temp = s[i + 1]; s[i + 1] = s[i]; s[i] = temp; flag = 1; break; } } if (flag == 1) { cout << "YES" << '\n'; cout << i + 1 << " " << i + 2 << '\n'; } else { cout << "NO" << '\n'; } }
#include <bits/stdc++.h> int main() { int l; scanf("%d", &l); char a[l]; scanf("%s", a); int flag = 0; int b, c; for (int i = 0; i < l - 1; i++) { if (a[i + 1] < a[i]) { flag = 1; b = i + 1; c = b + 1; break; } } if (flag == 0) printf("NO\n"); else { printf("YES\n%d %d", b, c); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES\n" << i + 1 << ' ' << i + 2; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; string to_string(string s) { return '"' + s + '"'; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } long long mod_1097(long long a) { long long mod_a; if (a > 1000000007) { mod_a = a % 1000000007; } else { mod_a = a; } return mod_a; } vector<long long> get_primes(long long n) { vector<long long> primes = {}; vector<long long> nums(n, 0); for (long long i = 2; i < n; i++) { if (nums[i] == 0) { primes.push_back(i); for (long long j = i * 2; j < n; j += i) { nums[j] = i; } } } return primes; } vector<long long> sieve(long long n) { vector<long long> res(n + 1, 0); res[n] = n; for (int i = 2; i < pow(n, 1 / 2); i++) { long long shuttle = i * i; while (shuttle < n) { res[shuttle] = i; shuttle += i; } } return res; } long long ceil_(long long a, long long b) { if (a % b == 0) { return a / b; } else { return a / b + 1; } } long long gcd(long long a, long long b) { for (;;) { if (a == 0) return b; b %= a; if (b == 0) return a; a %= b; } } long long lcm(long long a, long long b) { long long temp = gcd(a, b); return temp ? (a / temp * b) : 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; string s; cin >> s; int max_c = s[0] - 'a'; int max_c_pos = 0; for (int i = 1; i < n; i++) { ; ; if ((s[i] - 'a') < max_c) { cout << "YES" << endl; cout << max_c_pos + 1 << " " << i + 1 << endl; return 0; } else { max_c = s[i] - 'a'; max_c_pos = i; } } cout << "NO" << endl; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int n; string s; int main() { cin >> n >> s; int MAX = 0; for (int i = 1; i < s.size(); i++) { if (s[i] >= s[MAX]) MAX = i; else { printf("YES\n%d %d\n", MAX + 1, i + 1); return 0; } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; int n = 0; cin >> n; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, k; cin >> n; string s; cin >> s; for (i = 1; i < n; i++) { if (s[i] < s[i - 1]) { cout << "YES\n"; cout << i << " " << i + 1 << '\n'; return 0; } } cout << "NO\n"; }
#include <bits/stdc++.h> using namespace std; int N; string s; int main() { scanf("%d", &N); cin >> s; int temp = -1; for (int i = 1; s[i]; i++) { if (s[i] < s[i - 1]) { temp = i; break; } } if (temp == -1) printf("NO\n"); else { printf("YES\n"); temp += 1; printf("%d %d\n", temp - 1, temp); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int vect[20005]; int main() { cin >> n; string s; cin >> s; for (int i = 0; i < n - 1; i++) if (s[i] > s[i + 1]) { cout << "YES" << "\n"; cout << i + 1 << " " << i + 2; return 0; } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s; cin >> s; long long int temp = 0; for (long long int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2 << endl; temp = 1; break; } } if (temp == 0) cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int maxn = 5e5 + 10; const double pi = acos(-1); int main() { int n; string s, ss; cin >> n >> s; ss = s; sort(ss.begin(), ss.end()); if (ss == s) { cout << "NO" << endl; return 0; } cout << "YES" << endl; int pos1 = 0; while (ss[pos1] == s[pos1]) pos1++; int pos2 = pos1 + 1; for (int i = pos1 + 1; i <= n - 1; ++i) if (s[i] <= ss[pos2]) { pos2 = i; break; } cout << pos1 + 1 << " " << pos2 + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 4 * 10e5; const long long MX = -1e9 - 3; const long long MN = 1e9 + 3; long long n, m, cnt, ans, x, a, b, mx = MX, mn = MN, c; bool bl; string str = "ACTG", s; map<char, long long> mp; vector<long long> v, q; pair<char, long long> pr[N]; pair<long long, char> pr1[N]; int main() { ios_base::sync_with_stdio(0); cin >> n >> s; for (long long i = 0; i < s.size() - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES\n" << i + 1 << " " << i + 2; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> int main() { int num_lets; std::cin >> num_lets; char last_char = 0; char now_char = getchar(); for (int i = 0; i < num_lets; ++i) { last_char = now_char; now_char = getchar(); if (last_char > now_char) { std::cout << "YES\n" << i << ' ' << i + 1; return 0; } } std::cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 50, MOD = 1e9 + 7; signed main() { ios::sync_with_stdio(false); cin.tie(0); string s; long long n; cin >> n; char c = 'A'; long long imax = 0; cin >> s; for (long long i = 0; i < s.size(); i++) { if (c == 'A') c = s[i], imax = 0; if (c < s[i]) c = s[i], imax = i; else if (c > s[i]) { cout << "YES" << endl; cout << imax + 1 << ' ' << i + 1; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { printf("YES\n%d %d\n", i + 1, i + 2); return 0; } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; string t = s; sort(t.begin(), t.end()); if (t == s) { return 0 * puts("NO"); } puts("YES"); for (int i = 0; i < s.size() - 1; i++) { if (s[i] > s[i + 1]) { swap(s[i], s[i + 1]); cout << i + 1 << " " << i + 2 << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n, k, c = 0; cin >> n; string s; cin >> s; for (long long i = 0; i < s.length() - 1; i++) { if (s[i + 1] < s[i]) { k = i; c = 1; break; } } if (c == 0) cout << "NO"; else { cout << "YES" << endl; cout << k + 1 << " " << k + 2; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int c = 0; int i; for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { c = 1; break; } } if (c == 1) cout << "YES\n" << i + 1 << " " << i + 2 << "\n"; else cout << "NO\n"; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long int rvsr(long long int n) { string s = to_string(n); reverse(s.begin(), s.end()); stringstream obj(s); obj >> n; return n; } long long int power(long long int x, long long int y) { long long int res = 1; x = x; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } long long int logtwo(long long int n) { if (n == 1) return 0; return logtwo(n / 2) + 1; } long long int isprime(long long int n) { for (long long int c1 = 2; c1 * c1 <= n; c1++) { if (n % c1 == 0) { return 0; } } return 1; } long long int twop(long long int n) { long long int x = 0; while (n % 2 == 0) { n /= 2; x++; } return x; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } long long int t, n; int c[70]; bool compare(string &s1, string &s2) { return s1.size() < s2.size(); } int isSubstring(string s1, string s2) { int M = s1.length(); int N = s2.length(); for (int i = 0; i <= N - M; i++) { int j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j]) break; if (j == M) return i; } return -1; } void solve() { long long int n; cin >> n; string s; cin >> s; char x = s[0]; int h = 0, l = 0; for (long long int i = 0; i < s.length(); i++) { if (s[i] > x) { x = s[i]; l = i; } else { if (s[i] < x && h == 0) { h = i; break; } } } if (h) { cout << "YES\n"; cout << l + 1 << " " << h + 1 << "\n"; } else { cout << "NO\n"; } return; } int main() { t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)1e9 + 7; const long double PI = 3.141592653589793238462643383279502884197; priority_queue<int, vector<int>, greater<int> > pq; vector<int> v; char s[300001]; int main() { int n; scanf("%d", &n); scanf("%s", s); int mav = s[0], mavi = 0; for (int i = 1; i < n; i++) { if (s[i] < mav) return !printf("YES\n%d %d", mavi + 1, i + 1); if (mav < s[i]) { mav = s[i]; mavi = i; } } printf("NO"); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; string s; cin >> s; char mx = s[0]; int fans, secans; fans = 1; bool notok = true; for (int i = 1; i < n; i++) { if (s[i] < mx) { secans = i + 1; notok = false; break; } else { fans = i + 1; mx = s[i]; } } if (notok) { cout << "NO"; } else { cout << "YES\n"; cout << fans << ' ' << secans; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; string s; cin >> s; int x = 0; for (int i = 0; i < a - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; void solve() { int n; string s; cin >> n >> s; string t = s; sort((t).begin(), (t).end()); if (t == s) { cout << "NO" << endl; } int k = 0; while (s[k] == t[k]) { k++; } for (int i = k; i < n; i++) { if (s[i] < s[k]) { cout << "YES" << endl; cout << k + 1 << " " << i + 1 << endl; return; } } } int main() { int t; t = 1; for (int i = 1; i <= t; i++) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int mod = 1e9 + 7; string s; int n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s; for (int i = 0; i < n - 1; ++i) { if (s[i] > s[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; void solver() { int n; cin >> n; string s; cin >> s; int l = s.length(); for (int i = 0; i <= l - 2; i++) { if (s[i + 1] < s[i]) { cout << "YES \n" << i + 1 << " " << i + 2; return; } } cout << "NO\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) solver(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; char s[333333]; scanf("%d%*c%s", &n, s); for (i = 1; i < n; i++) { if (s[i - 1] > s[i]) { cout << "YES" << endl << i << " " << i + 1 << endl; return 0; } } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; vector<ll> v; int main() { std::ios::sync_with_stdio(false); string s; ll n; cin >> n; cin >> s; for (int i = 0; i < n - 1; ++i) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << (i + 1) << " " << (i + 2) << endl; return 0; } } cout << "NO" << endl; }
#include <bits/stdc++.h> int main() { long long int n; int pos = 0, k = 0; scanf("%lld", &n); char s[n]; int x, y; scanf("%s", s); if (n == 1 || n == 0) { pos = -1; } for (int i = 0; i < n - 1; i++) { x = s[i]; y = s[i + 1]; if (x > y) { pos = i; break; } else pos = -1; } if (pos >= 0) { printf("YES\n%d %d", pos + 1, pos + 2); } else { printf("NO"); } }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; for (long long i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> char s[300010]; int main() { int n, l = 1, r = 1; scanf("%d", &n); scanf("%s", &s); char max = s[0]; for (int i = 0; i < n; i++) { if (s[i] < max) { r = i + 1; printf("YES\n"); printf("%d %d\n", l, r); return 0; } if (s[i] > max) { max = s[i]; l = i + 1; } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); ; int n; cin >> n; string s; cin >> s; map<char, int> mp; for (int i = 0; i < n; i++) mp[s[i]] = i; for (int i = 0; i < n; i++) { char x = s[i]; for (char c = 'a'; c < x; c++) { if (mp[c] > i) return (cout << "YES\n" << i + 1 << " " << (mp[c] + 1), 0); } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; string ini, iniS; int n; int main() { cin >> n >> ini; iniS = ini; sort(iniS.begin(), iniS.end()); for (int i = 0; i < n; i++) { if (iniS[i] < ini[i]) { for (int j = i + 1; j < n; j++) { if (iniS[i] == ini[j]) { printf("YES\n%d %d", i + 1, j + 1); return 0; } } } } printf("No"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long n; cin >> n; string s; cin >> s; for (long long i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2 << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; scanf("%lld", &n); char str[n]; scanf("%s", str); unordered_map<char, long long int> make_pair; make_pair[str[0]] = 1; for (long long int i = 1; i < n; ++i) { for (char c = str[i] + 1; c <= 'z'; c++) { if (make_pair.find(c) != make_pair.end()) { printf("%s", "YES\n"); printf("%lld", make_pair[c]); printf("%s", " "); printf("%lld", i + 1); printf("\n"); return 0; } } make_pair[str[i]] = i + 1; } printf("%s", "NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long n; string s; cin >> n >> s; for (int i = 1; i < n; i++) { if (s.at(i) < s.at(i - 1)) { cout << "YES" << endl; cout << i << " " << i + 1; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7; const ll INF = 1e18, MOD = 1e15 + 37; const ld PI = acos(-1); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << setprecision(13) << fixed; int n; cin >> n; string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES\n"; cout << i + 1 << " " << i + 2 << "\n"; return 0; } } cout << "NO\n"; }
#include <bits/stdc++.h> int main() { size_t n; scanf("%zu", &n); char buf[300010]; scanf("%s", buf); std::string s = buf; for (size_t i = 1; i < n; ++i) if (s[i - 1] > s[i]) { std::swap(s[i - 1], s[i]); puts("YES"); printf("%zu %zu\n", i, i + 1); return 0; } puts("NO"); }
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 30; const long long INFL = 1LL << 60; const long long mod = 1000000009; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; for (int i = 0; i < int(n - 1); i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << ' ' << i + 2 << endl; return 0; } } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char x[n]; scanf("%s", x); char dup[n]; for (int i = 0; i < n; i++) dup[i] = x[i]; sort(dup, dup + n); bool flag = false; for (int i = 0; i < n; i++) { if (x[i] != dup[i]) flag = true; } if (!flag) cout << "NO"; else { cout << "YES" << endl; int pos, pos1; for (int i = 0; i < n - 1; i++) { if (x[i] > x[i + 1]) { pos = i, pos1 = i + 1; break; } } cout << pos + 1 << " " << pos1 + 1; } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("avx,avx2,fma") using namespace std; long long power(long long a, long long b) { long long res = 1; a = a % 1000000007; while (b > 0) { if (b & 1) { res = (res * a) % 1000000007; } a = (a * a) % 1000000007; b >>= 1; } return res; } long long fermat_inv(long long y) { return power(y, 1000000007 - 2); } long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } void solve() { long long n; cin >> n; string s; cin >> s; long long f = -1; for (long long i = 0; i < n - 1; i++) { if (s[i + 1] < s[i]) { f = i; break; } } if (f == -1) { cout << "NO"; } else { cout << "YES\n"; cout << f + 1 << " " << f + 2; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long T = 1; while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; string s; cin >> n; cin >> s; n = s.size(); for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) break; } if (i != n - 1) { cout << "YES" << "\n"; cout << i + 1 << " " << i + 2 << "\n"; } else { cout << "NO" << "\n"; } }
#include <bits/stdc++.h> using namespace std; string s; int main() { int n; cin >> n; cin >> s; for (int i = 0; i < s.size() - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2 << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; cin >> n >> str; for (int i = 1; i < n; ++i) { if (str[i - 1] > str[i]) { cout << "YES\n" << i << ' ' << i + 1; return 0; } } cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; int pos = 0; for (long long i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES" << endl; cout << i + 1 << " " << i + 2; pos = 1; break; } } if (pos == 0) cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int mx = 3e6 + 10; int a[mx], b[mx]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, t; cin >> n; string s; cin >> s; int i, f = 0; for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { f = 1; t = i; break; } } if (f == 0) { cout << "NO"; return 0; } cout << "YES\n"; if (t == 0) cout << 1 << " " << 2; else cout << t + 1 << " " << t + 2; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int ans = -1; for (int i = 0; i < n - 1; i++) { if (s[i + 1] < s[i]) { ans = i; break; } } if (ans == -1) cout << "NO"; else { cout << "YES" << endl; cout << ans + 1 << " " << ans + 2 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long mod = pow(10, 9) + 7; int gcdExtended(int a, int b, int *x, int *y); int modInverse(int b, int m) { int x, y; int g = gcdExtended(b, m, &x, &y); if (g != 1) return -1; return (x % m + m) % m; } int gcdExtended(int a, int b, int *x, int *y) { if (a == 0) { *x = 0, *y = 1; return b; } int x1, y1; int gcd = gcdExtended(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd; } string decimalToBinary(int n) { string s = bitset<64>(n).to_string(); const auto loc1 = s.find('1'); if (loc1 != string::npos) return s.substr(loc1); return "0"; } int binaryToDecimal(int n) { int num = n; int dec_value = 0; int base = 1; int temp = num; while (temp) { int last_digit = temp % 10; temp = temp / 10; dec_value += last_digit * base; base = base * 2; } return dec_value; } unsigned long long sumbincoef(int N, int k) { unsigned long long bincoef = 1, sum = 1; int i; for (i = 1; i < k; ++i) { bincoef = (bincoef * (N - i + 1) / i); sum += bincoef; } return sum; } bool is_prime(long long n) { if (n == 1) { return false; } long long i = 2; while (i * i <= n) { if (n % i == 0) { return false; } i += 1; } return true; } int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int nCrModp(int n, int r, int p) { if (r > n - r) r = n - r; int C[r + 1]; memset(C, 0, sizeof(C)); C[0] = 1; for (int i = 1; i <= n; i++) { for (int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p; } return C[r]; } bool is_palindrome(string s) { int n = s.size(); for (int i = 0; i < (int)n / 2; i++) { if (s[i] == s[n - 1 - i]) { } else { return false; } } return true; } const int N = 200000 + 10; long long factorialNumInverse[N + 1]; long long naturalNumInverse[N + 1]; long long fact[N + 1]; void InverseofNumber(long long p) { naturalNumInverse[0] = naturalNumInverse[1] = 1; for (int i = 2; i <= N; i++) naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; } void InverseofFactorial(long long p) { factorialNumInverse[0] = factorialNumInverse[1] = 1; for (int i = 2; i <= N; i++) factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; } void factorial(long long p) { fact[0] = 1; for (int i = 1; i <= N; i++) { fact[i] = (fact[i - 1] * i) % p; } } long long Binomial(long long N, long long R, long long p) { long long ans = ((fact[N] * factorialNumInverse[R]) % p * factorialNumInverse[N - R]) % p; return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); mt19937 rng( (unsigned int)chrono::steady_clock::now().time_since_epoch().count()); int t = 1; while (t > 0) { int n; cin >> n; string s; cin >> s; char maxi = s[0]; int index = 0; for (int i = 1; i < n; i++) { if (maxi < s[i]) { maxi = max(maxi, s[i]); index = i; } if (maxi > s[i]) { cout << "YES" << endl; cout << index + 1 << " " << i + 1 << endl; return 0; } } cout << "NO" << endl; t--; } }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3fll; const int MOD = 1e9 + 7; const int MAX = 1e5 + 10; int main() { ios::sync_with_stdio(false); cin.tie(0); ; int n, m; cin >> n; string st; cin >> st; int alfa[27]; memset(alfa, -1, sizeof(alfa)); int final = 'z' - 'a'; for (int i = 0; i < n; i++) { int letter = st[i] - 'a'; for (int j = letter + 1; j <= final; j++) { if (alfa[j] != -1) { cout << "YES" << endl; cout << alfa[j] << " " << i + 1 << endl; return 0; } } alfa[letter] = i + 1; } cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int mx = -1; int x = 0, y = n + 1; for (int i = 0; i < n; i++) { if ((s[i] - 97) > mx) { x = i + 1; mx = s[i] - 97; } else if ((s[i] - 97) < mx) { y = i + 1; break; } } if (y == n + 1) { cout << "NO" << endl; } else { cout << "YES" << endl; cout << x << ' ' << y << ' ' << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; char temp; int n; s2 = ""; cin >> n; cin >> s1; s2 = s1; for (int i = 0; i < n - 1; ++i) { if (s2[i] > s2[i + 1]) { cout << "YES" << endl << i + 1 << " " << i + 2; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; const int mod = 1e9 + 7; char s[maxn]; int main() { int n; cin >> n; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { cout << "YES\n"; cout << i + 1 << " " << i + 2; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e, k[30]; string s; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> a >> s; for (b = 1; b < a; b++) { if (s[b] < s[b - 1]) { cout << "YES" << endl; cout << b << " " << b + 1; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(0); cin.tie(0); int n; string s; cin >> n >> s; int l = -1, r = -1; for (int i = s.size() - 2; i >= 0; i--) { if (s[i] > s[i + 1]) { l = i; r = i + 1; break; } } if (l == -1) cout << "NO" << "\n"; else { cout << "YES" << "\n"; cout << l + 1 << " " << r + 1 << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 200; const long long MOD = 1e9 + 7; long long n, pos, v[N]; string s; char c; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) { v[s[i]] = i; } for (int i = 0; i < s.size(); i++) { for (int j = 'a'; j < s[i]; j++) if (v[j] > i) { cout << "YES" << "\n" << i + 1 << " " << v[j] + 1; return 0; } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; char s[1000100]; int num[27]; int main() { int n; cin >> n; scanf("%s", s + 1); int len = strlen(s + 1); for (int i = len; i >= 1; i--) { num[s[i] - 'a'] = i; for (int j = s[i] - 'a' - 1; j >= 0; j--) { if (num[j]) { cout << "YES\n"; cout << i << " " << num[j] << endl; return 0; } } } cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, i, id = 0, id2 = 0; cin >> x; string s; cin >> s; char ch = s[x - 1]; for (i = 0; i < x - 1; i++) { if ((s[i] - '0') > s[i + 1] - '0') { id = i + 1; id2 = i + 2; break; } } if (id > 0) { cout << "YES" << endl; cout << id << " " << id2 << endl; } else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; char str[maxn]; int main() { int n; scanf("%d", &n); scanf("%s", str); int mmax = str[0] - 'a', pos = 0, ok = 1; for (int i = 1; i < n; i++) { if (mmax < str[i] - 'a') { mmax = str[i] - 'a'; pos = i; } else if (str[i] - 'a' < mmax) { printf("YES\n"); printf("%d %d\n", pos + 1, i + 1); ok = 0; break; } } if (ok) printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; short int dx[4] = {0, 0, 1, -1}; short int dy[4] = {1, -1, 0, 0}; short int dxx[8] = {0, 0, 1, -1, 1, -1, 1, -1}; short int dyy[8] = {1, -1, 0, 0, 1, -1, -1, 1}; long long int x[100000]; int main() { cin >> x[0]; string y; cin >> y; long long int a = 0, b, c, d, e; for (int i = 0; i < y.length() - 1; i++) if (y[i] <= y[i + 1]) a++; else { cout << "YES" << endl << i + 1 << ' ' << i + 2; return 0; } cout << "NO"; }
#include <bits/stdc++.h> int main() { int n, i, j, temp; scanf("%d", &n); char s[n]; scanf("%s", &s); for (i = 0; i < n; i++) { if (s[i] > s[i + 1] && i + 1 < n) { printf("YES\n"); printf("%d %d", i + 1, i + 2); return 0; } } printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int count = 0, c = 1; char t = s[0]; for (int i = 0; i < n - 1; i++) { if (s[i] <= s[i + 1]) { t = s[i + 1]; c = i + 2; } if (s[i + 1] < t) { cout << "YES" << "\n" << c << " " << i + 2; count++; break; } } if (count == 0) cout << "NO"; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 1e6 + 10; string l; int main() { int n; scanf("%d", &n); cin >> l; bool flag = false; int x, y; for (int i = 0; i < n - 1; ++i) { if (l[i + 1] < l[i]) { flag = true; y = i + 2; x = i + 1; break; } } if (flag) { cout << "YES" << endl; cout << x << " " << y << endl; } else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; int gg = -1; int l = 0, r = n; bool ok = 0; for (int i = 0; i < n; i++) { int x = s[i] - 'a'; if (x < gg) { ok = 1; r = i + 1; break; } if (x > gg) { l = i + 1; gg = x; } } if (ok) { cout << "YES" << endl; cout << l << ' ' << r << endl; } else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, q1, q2; char l; cin >> n; cin >> l; q2 = (int)l; for (i = 1; i < n; i++) { cin >> l; q1 = q2; q2 = (int)l; if (q1 > q2) { cout << "YES" << endl << i << ' ' << i + 1; return 0; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; const int MOD1 = 1e9 + 7; const int MOD2 = 998244353; const long long INF = 2 * 1e18; const long double PI = 3.14159265358979323846; int main() { long long n, cur = -1, cnt = -1; string s; cin >> n >> s; for (long long i = 0; i < n; i++) { if (i == 0) { cnt++; cur = s[i] - 'a'; continue; } if (cur > s[i] - 'a') { cout << "YES\n" << cnt + 1 << " " << i + 1; return 0; } else { cur = s[i] - 'a'; cnt++; } } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n; cin >> s; string s1 = s; sort(s.begin(), s.end()); if (s1 == s) { cout << "NO"; } else { for (int i = 0; i < n; i++) { if (s[i] != s1[i]) { for (int j = i + 1; i < n; j++) { if (s1[i] > s1[j]) { cout << "YES" << endl; cout << i + 1 << " " << j + 1; return 0; } } } } } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; string s; cin >> n >> s; for (int i = 1; i < s.size(); i++) { if (s[i] < s[i - 1]) { cout << "YES" << endl; cout << i << " " << i + 1; return 0; } } cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char arr[300001]; int main(void) { int N; scanf("%d", &N); scanf("%s", arr); int i; char _max = 0; int idx = -1; for (i = 0; i < N; i++) { if (_max < arr[i]) { _max = arr[i]; idx = i; } if (idx != -1 && _max > arr[i]) { printf("YES\n"); printf("%d %d\n", idx + 1, i + 1); return 0; } } printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; void guan() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } const int maxn = 2234567; const int mod = 1e6 + 3; const long long MAXX = (1ll << 62) - 1 + (1ll << 62); long long a[maxn], b[maxn]; void solve(int n, string s) { for (int i = 1; i < n; i++) { if (s[i] < s[i - 1]) { cout << "YES" << endl; cout << i << " " << i + 1 << endl; return; } } cout << "NO" << endl; } int main() { guan(); int T = 1; int n, k, m; int x; string s; while (cin >> n >> s) { solve(n, s); } return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; bool flag = false; for (int i = 1; i < n; i++) { if (s[i] < s[i - 1]) { flag = true; char ch = s[i]; s[i] = s[i - 1]; s[i - 1] = ch; cout << "YES" << endl; cout << i << " " << i + 1 << endl; break; } } if (!flag) { cout << "NO" << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { cin >> n; cin >> s; bool isget = false; int i; for (i = 1; i < n; i++) { if (s[i] < s[i - 1]) { isget = true; break; } } if (isget) { cout << "YES" << endl; cout << i << " " << i + 1; } else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { iostream::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; char c; char max_char; int max_pos = 0; cin >> max_char; for (int i = 0; i < n - 1; ++i) { cin >> c; if (c < max_char) { cout << "YES" << "\n"; cout << max_pos + 1 << " "; cout << i + 2 << "\n"; return 0; } else { max_char = c; max_pos = i + 1; } } cout << "NO" << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int l, r, i; for (i = 1; i < n; ++i) { if (s[i] < s[i - 1]) { l = i - 1; r = i; break; } } if (i != n) { cout << "YES" << endl; cout << l + 1 << " " << r + 1; } else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, flag = 0; cin >> n; string str; cin >> str; for (long long int(i) = 0; (i) < ((long long int)str.size() - 1); (i)++) { if (str[i + 1] < str[i]) { flag = 1; cout << "YES" << "\n"; cout << i + 1 << " " << i + 2 << "\n"; break; } } if (flag == 0) cout << "NO" << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, i; string str, cpy; cin >> n; cin >> str; cpy = str; reverse(cpy.begin(), cpy.end()); sort(cpy.begin(), cpy.end()); if (cpy == str) { cout << "NO"; return 0; } else { for (i = 0; str[i]; i++) { if (str[i] > str[i + 1]) { cout << "YES\n"; cout << i + 1 << ' ' << i + 2; return 0; } } } }
#include <bits/stdc++.h> using namespace std; string s; string t; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; cin >> s; for (int i = 1; i < s.size(); i++) if (s[i] < s[i - 1]) { cout << "YES\n"; cout << i << ' ' << i + 1; return 0; } cout << "NO"; }
#include <bits/stdc++.h> using namespace std; string a; int main() { int n; cin >> n; cin >> a; int flg = 0; int p, q; for (int i = 1; i < n; i++) { if (a[i] >= a[i - 1]) { continue; } else { flg = 1; p = i + 1; q = i; break; } } if (flg) { cout << "YES\n"; cout << q << " " << p << endl; } else { cout << "NO\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; char ch[MAXN]; int num[999]; int vis[999]; int n, m, t; int match(int l, int r) { for (int i = 0; i <= r - l; i++) { if (ch[l + i] < ch[r - i]) return 0; if (ch[l + i] > ch[r - i]) return 1; } return 0; } int main() { memset(num, 0x3f, sizeof num); cin >> n; cin >> ch + 1; int len = strlen(ch + 1); for (int i = 1; i <= n; i++) { char xiao = ch[i]; for (int j = 1; j <= 26; j++) { if (xiao < 'a' + j - 1 && vis[j + 'a' - 1]) { cout << "YES" << endl << num[j + 'a' - 1] << ' ' << i; return 0; } } num[ch[i]] = i; vis[ch[i]] = 1; } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, f = 0, p; cin >> n; string s; cin >> s; for (i = 1; i < n; i++) { if (s[i] < s[i - 1]) { f = 1; p = i - 1; break; } } if (f == 1) cout << "YES\n" << p + 1 << " " << p + 2 << "\n"; else cout << "NO\n"; }
#include <bits/stdc++.h> int main() { int n; std::cin >> n; std::string s; std::cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { std::cout << "YES\n" << i + 1 << " " << i + 2; return 0; } } std::cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, x, y, t; int a[300055]; char ch; int main() { scanf("%d", &n); ch = getchar(); while (ch < 'a' || ch > 'z') ch = getchar(); while (ch >= 'a' && ch <= 'z') a[++i] = ch - 'a', ch = getchar(); for (i = 1; i <= n - 1; i++) if (a[i] > a[i + 1]) { printf("YES\n%d %d", i, i + 1); return 0; } printf("NO"); return 0; }