/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 476.0 KiB
#2 Accepted 1ms 348.0 KiB
#3 Accepted 1ms 488.0 KiB
#4 Wrong Answer 1ms 320.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Wrong Answer 1ms 488.0 KiB

Code

#include <bits/stdc++.h>
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set1;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set2;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_s;
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_s2;
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const int N = 1200300;
#define pi 2 * acos(0.0)
#define vll vector<ll>
#define pq_ priority_queue
#define pq_min <int,vector<int>,greater<int>>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pb push_back
#define sp ' '
#define sz(n) (int)n.size()
#define all(n) n.begin(), n.end()
#define rall(n) n.rbegin(), n.rend()
#define YES cout << "YES\n";
#define yes cout << "yes\n";
#define NO cout << "NO\n";
#define no cout << "no\n";
#define bye return 0;
#define ss second;
#define ff first;
const double eps = 1e-9;
const int MAX = 1e5;
const int lim = 1e6;
bool odd(ll num) { return ((num & 1) == 1); }
bool even(ll num) { return ((num & 1) == 0); }
bool isEqual(double a, double b) { return abs(a - b) < eps; }
bool isGreater(double a, double b) { return a >= b + eps; }
bool isGreaterEqual(double a, double b) { return a > b - eps; }
#define tc     \
    int tt;    \
    cin >> tt; \
    while (tt--)
#define mset(n, v) memset(n, v, sizeof(n))
#define chk(n) for (auto it : n)
#define ff1(i, n) for (int i = 1; i <= n; i++)
#define lcm(a, b) (((a) * (b)) / __gcd(a, b))
int dx[8] = {1, -1, 0, 0, 1, -1, -1, 1};
int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll mn(ll x, ll y)
{
    if (x < y)
        return x;
    else
        return y;
}
ll maxx(ll x, ll y)
{
    if (x > y)
        return x;
    else
        return y;
}std::vector<int> bin(int n) {
    std::vector<int> binary;
    
    while (n > 0) {
        binary.push_back(n % 2);
        n /= 2;
    }
 
    // Reverse the vector to get the binary representation in correct order
    std::reverse(binary.begin(), binary.end());
    
    return binary;
}
 
int ispal(int n)
{
 
    vi v = bin(n);
    int f = 0;
    for (int i = 0, j = v.size() - 1; i < v.size() / 2; i++, j--)
    {
        if (v[i] != v[j])
            f = 1;
    }
    if (!f)
        return 1;
    return 0;
}
 
ll POW(ll a, ll b)
{
    if (!b)
        return 1;
    ll r = POW(a, b / 2);
    if (b % 2)
        return r * r * a;
    else
        return r * r;
}
void pri(vi v)
{
    for (auto it : v)
        cout << it << ' ';
    cout << endl;
}
void pro(vll v)
{
    for (auto it : v)
        cout << it << ' ';
    cout << endl;
}
int mex(vi v, int l, int r)
{
    vi a;
    for (int i = l; i <= r; i++)
    {
        a.pb(v[i]);
    }
    sort(all(a));
    for (int i = 0, j = 1; i < a.size(); i++)
    {
        if (a[i] == j)
        {
            j++;
        }
        else
        {
            return j;
        }
    }
    return a.back() + 1;
}
vector<int> cps(const vector<int> &arr)
{
    int n = arr.size();
    vector<int> prefixSum(n);
 
    if (n > 0)
    {
        prefixSum[0] = arr[0];
        for (int i = 1; i < n; ++i)
        {
            prefixSum[i] = prefixSum[i - 1] + arr[i];
        }
    }
 
    return prefixSum;
}
 
 
 
bool comp(pair<int, int> x, pair<int, int> y)
{
    if (x.second < y.second)
        return true;
    else if (x.second == y.second)
    {
        if (x.first > y.first)
            return true;
        else
            return false;
    }
    else
        return false;
}
ll PoW(ll base, ll exponent) {
    ll result = 1;
    for (int i = 0; i < exponent; ++i) {
        result *= base;
        if (result > 1000000) {
            return -1; 
        }
    }
    return result;
}
 
bool isp(ll num) {
    ll om = num;
    ll rm = 0;
    while(num>0) {
        ll digit = num % 10;
        rm = rm * 10 + digit;
        num /= 10;
    }
    return om == rm;
}
string lcs(const std::vector<std::string>& strs) {
    std::vector<std::string::const_reverse_iterator> backs;
    std::string s;  
    if (strs.size() == 0) return "";
    if (strs.size() == 1) return strs[0]; 
    for (auto& str : strs) backs.push_back(str.crbegin()); 
    while (backs[0] != strs[0].crend()) {
        char ch = *backs[0]++;
        for (std::size_t i = 1; i<strs.size(); i++) {
            if (backs[i] == strs[i].crend()) goto done;
            if (*backs[i] != ch) goto done;
            backs[i]++;
        }
        s.push_back(ch);
    }  
done:
    reverse(s.begin(), s.end());
    return s;
}
bool leap(int year) {
    return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
}
bool isd(string s,ll d , ll y)
{
    if(d==32) return 0;
    if(s=="April"|| s=="June"|| s=="September"|| s=="November")
    {
        if(d==31) return 0;
        return 1;
    }
    if(d>28 && s=="February")
    {
         if(d==29 && leap(y))
         {
            return 1;
         }  
         return 0; 
    }
    return 1;
}
vll pref(vll v)
{
    vll pr;
    pr.pb(v.front());
    for(int i=1;i<v.size();i++)
    {
        pr.pb(v[i]+pr[i-1]);
    }
    return pr;
}
ll cxor(vi v, ll l,ll r)
{
    ll xo=v[l];
    for(int i=l+1;i<=r;i++)
    {
        xo^=v[i];
    }
    return xo;
}
#define seea(a,x,y) for(int i=x;i<y;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
#define sees(s,n) for(int i=0;i<n;i++){int x; cin>>x; s.insert(x);}
ll sup(vi arr)
{
    sort(all(arr));
    ll n=arr.size();   
    ll sum = 0;
    for(ll i = 0; i < n; i++){
        sum += i*arr[i] - (n-1-i)*arr[i];
    }
         
    return sum;
}
int main()
{
  ll n, k;
  cin>>n>>k;
  vi v;
  seev(v, n);
  ll l=-1, r=-1;
  if(is_sorted(all(v))){
    YES;
    cout<<1<<' '<<1<<endl;
    return 0;
  }
   
  for(int i=0;i<n;i++){
    if(v[i]!=i+1 && l==-1){
        l=i;
    }
    else if(v[i]!=i+1){
        r=i;
    }
  }
//   cout<<l<<' '<<r<<endl;
  sort(v.begin()+l, v.begin()+r+1);
  if(r-l+1<=k && is_sorted(all(v))){
    YES;
    cout<<l+1<<' '<<r+1<<endl;
    return 0;
  }
  NO;
  
}   

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 15:26:27
Judged At
2024-11-11 02:30:41
Judged By
Score
9
Total Time
1ms
Peak Memory
532.0 KiB