/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Wrong Answer 2ms 332.0 KiB
#3 Accepted 596ms 2.797 MiB
#4 Wrong Answer 612ms 8.926 MiB
#5 Wrong Answer 472ms 7.086 MiB
#6 Wrong Answer 446ms 2.391 MiB
#7 Accepted 2ms 352.0 KiB
#8 Accepted 2ms 332.0 KiB
#9 Wrong Answer 778ms 8.496 MiB
#10 Wrong Answer 812ms 10.391 MiB

Code

#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

void fastio(){ios::sync_with_stdio(false);cin.tie(0);}

vector<ll> take_inputs_0(ll n){vector<ll> v(n);for(int i=0;i<n;i++){cin>>v[i];}return v;}
vector<ll> take_inputs_1(ll n){vector<ll> v(n);for(int i=1;i<n;i++){cin>>v[i];}return v;}

void show(auto x){ cout<<x<<"\n";}
void show1(auto v){ ll n=(signed)v.size();for(int i=0;i<n;i++){cout<<v[i]<<" ";}cout<<"\n";}
void show2(auto v){ ll n=(signed)v.size();for(int i=0;i<n;i++){	cout<<v[i]<<"\n";}}

void sort_it(auto &v){ sort(v.begin(),v.end());}
void reverse_it(auto &v){ reverse(v.begin(),v.end());}
void do_both(auto &v){ sort(v.begin(),v.end());reverse(v.begin(),v.end());}

auto find_max(auto v){ sort(v.begin(),v.end());reverse(v.begin(),v.end());return v[0];}
auto find_min(auto v){ sort(v.begin(),v.end());return v[0];}

vector<ll> bitRep64(ll n){vector<ll> v;int i=0;while(i<=63){if(n&(1LL<<i)){v.push_back(1);}else{v.push_back(0);}i++;}return v;}
vector<ll> bitRep32(ll n){vector<ll> v;int i=0;while(i<=31){if(n&(1LL<<i)){v.push_back(1);}else{v.push_back(0);}i++;}return v;}
vector<string> all_subset(ll n){vector<string> v;for(int i=0;i<(1<<n);i++){string st="";for(int j=0;j<n;j++){if(i&(1<<j)){st+="1";}else{st+="0";}}v.push_back(st);}return v;}

vector<ll> prefix_sum_0(vector<ll> v){ll n=(signed)v.size();for(int i=1;i<n;i++){v[i]=v[i-1]+v[i];}return v;}
vector<ll> prefix_sum_1(vector<ll> v){ll n=(signed)v.size();vector<ll> summ(n+1);for(int i=1;i<=n;i++){summ[i]=summ[i-1]+v[i-1];}return summ;}

///////////////////////////////////


int main()
{
	ll n;;cin>>n;
	
	vector<ll> v(n+1);
	
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	
	set<ll> st;
	
	for(int i=1;i<=n;i++)
	{
		if(i==1)
		{
			if(v[i]>v[i+1])
			{
				st.insert(i);
			}
		}
		else if(i==n)
		{
			if(v[i-1]>v[i])
			{
				st.insert(i);
			}
		}
		else
		{
			if(v[i-1]>v[i] || v[i]>v[i+1])
			{
				st.insert(i);
			}
		}
	}
	
	ll  q;cin>>q;
	
	while(q--)
	{
		ll x;cin>>x;
		
		if(x==1)
		{
			ll ind,val;cin>>ind>>val;
			
			st.erase(ind);
			
			v[ind]=val;
			
			if(n==1)
			{
				continue;
			}
			else if(n==2)
			{
				if(ind==1)
				{
					if(v[ind]>v[ind+1])
					{
						st.insert(1);
						st.insert(2);
					}
					else
					{
						st.erase(1);
						st.erase(2);
					}
				}
				else
				{
					if(v[ind-1]<v[ind])
					{
						st.insert(1);
						st.insert(2);
					}
					else
					{
						st.erase(1);
						st.erase(2);
					}
				}
			}
			else
			{
				if(ind==1)
				{
					if(v[ind]>v[ind+1])
					{
						st.insert(ind);
						st.insert(ind+1);
					}
					else if(v[ind+1]<=v[ind+2])
					{
						st.erase(ind+1);
					}
				}
				else if(ind==n)
				{
					if(v[ind]<v[ind-1])
					{
						st.insert(ind);
						st.insert(ind-1);
					}
					else if(v[ind-1]>=v[ind-2])
					{
						st.erase(ind-1);
						
					}
				}
				else
				{
					if(v[ind]>v[ind+1])
					{
						st.insert(ind);
						st.insert(ind+1);
						
					}
					
					if(v[ind]<v[ind-1])
					{
						st.insert(ind);
						st.insert(ind-1);
					}
				}
			}
		}
		else
		{
			ll l,r;cin>>l>>r;
			
			auto it=st.lower_bound(l);
			
			ll index=*it;
			
			
			if(l==r)
			{
				show("YES");
			}
			else if(st.size()==0)
			{
				show("YES");
			}
			else if(index>r)
			{
				show("YES");
			}
			else if(st.size()>0 && n==2)
			{
				show("NO");
			}
			else if(st.size()==0 && n==2)
			{
				show("YES");
			}
			else if(index>=l && index<=r)
			{
				if(index==l)
				{
					if(v[index+1]<v[index])
					{
						show("NO");
					}
					else
					{
						show("YES");
					}
				}
				else if(index==r)
				{
					if(v[index-1]>v[index])
					{
						show("NO");
					}
					else
					{
						show("YES");
					}
				}
				else
				{
					if(v[index-1]>v[index] || v[index]>v[index+1])
					{
						show("NO");
					}
					else
					{
						show("YES");
					}
				}
			}
			
		}
		
		
	
	}
	
	return 0;
} 

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-25 11:50:12
Judged At
2024-10-03 13:13:07
Judged By
Score
40
Total Time
812ms
Peak Memory
10.391 MiB