제출 #499750

#제출 시각아이디문제언어결과실행 시간메모리
499750The_SamuraiHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++98
13 / 100
495 ms30144 KiB
#include <bits/stdc++.h>
#define fcc ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sqr(a) (a) * (a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rebgin(), x.rend()
#define pb push_back
#define mp make_pair
#define int long long
#define ff first
#define ss second
#define endl "\n"
using namespace std;

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
int a[500009], b[500009];

void solve() {
	int n, m, l, r, k;
	
	cin >> n >> m;
	int a[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	a[0] = 0;
	int dp[n + 1];
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (a[i] < a[i - 1]) {
			dp[i]++;
		}
	}
	// 9 9 4 2 3 5
	//
	while (m--) {
		cin >> l >> r >> k;
		if (dp[r] - dp[l] == 0) {
			cout << "1\n";
		}
		else {
			cout << "0\n";
		}
	}
}

signed main() {
	fcc;
    int t = 1;
    
//    cin >> t;
    while (t--) {
    	solve();
    	cout << '\n';
  	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...