Compile Error
foo.cc: In function 'void solve()': foo.cc:23:8: error: redeclaration of 'long long int i' 23 | ll i=1,j=n; | ^ foo.cc:17:8: note: 'long long int i' previously declared here 17 | ll i,j; | ^ foo.cc:23:12: error: redeclaration of 'long long int j' 23 | ll i=1,j=n; | ^ foo.cc:17:10: note: 'long long int j' previously declared here 17 | ll i,j; | ^
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define endl '\n'
#define MIR183_PC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
void solve() {
// Your code here
ll n,k;
cin>>n>>k;
vector<ll> v(n+1);
for(ll i=1;i<=n;i++) cin>>v[i];
ll i,j;
if(is_sorted(v.begin()+1,v.end())) {
yes;
cout<<0<<" "<<0<<endl;
return;
}
ll i=1,j=n;
while (i<=n and v[i]==i)i++;
while (j>=1 and v[j]==j)j--;
ll dif=j-i+1;
if (dif<=k and dif>0){
yes;
cout<<i<<" "<<j<<endl;
}else{
no;
}
}
signed main() {
MIR183_PC;
// Always use ll, int may give TLE
ll tt;
tt=1;
// cin >> tt;
while (tt--) {
solve();
}
return 0;
}
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:31:43
- Judged At
- 2024-11-11 02:30:32
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes