답안 #1092918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092918 2024-09-25T11:17:04 Z Nurislam Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
308 ms 49620 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long


template <class F, class _S>
bool chmin(F &u, const _S &v){
	bool flag = false;
	if ( u > v ){
		u = v; flag |= true;
	}
	return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
	bool flag = false;
	if ( u < v ){
		u = v; flag |= true;
	}
	return flag;
}

const int N = 1e5+50, inf = 1e18+200;
//int mod = 998244353;
//int mod = 1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)


void solve(){
	
	
	
	int n, q;
	cin >>  n >> q;
	vector<int> a(n+1, 0);
	for(int i = 1; i <= n; i++)cin >> a[i];
	vector<int> pref(n+1, 0);
	for(int i = 1; i <= n; i++){
		pref[i] = pref[i-1];
		pref[i] += a[i] < a[i-1];
	}
	auto calc = [&](int l, int r) -> int{
		if(l > r)return 1;
		return (pref[r] == pref[l]);
	};
	
	while(q--){
		int l, r, k;
		cin >> l >> r >> k;
		int ans = calc(l+1, r);
		cout << ans << '\n';
		//cout << (ans <= k) << '\n';
	}
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 308 ms 49620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 4112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -