답안 #154567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154567 2019-09-22T17:56:50 Z hentai_lover Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 117588 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define lft(x) x * 2
#define rgt(x) x * 2 + 1

#define tm hui_pizda
#define ft first
#define sd second
#define pb push_back
#define pf push_front
#define sz size()
#define cnt continue
#define m_p make_pair
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
#define rf(i, r, l) for(int i = r; i >= l; -- i)
#pragma GCC optimize(-O3)
#pragma GCC optimize(Ofast)
#pragma GCC optimize("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

mt19937_64 rnd(time(NULL));

const ll N = 1e6 + 10;
const ll mtrxN = 10;
const ll oo = 1e18 + 10;
//const ll oo = 228;
const ll B = 500;
const ll mod = 1e9 + 7;

struct mtrx{
    ll m[mtrxN][mtrxN] = {};
};
mtrx mtrx_mult(mtrx a, mtrx b){
    mtrx c;
    fr(i, 0, mtrxN - 1){
        fr(j, 0, mtrxN - 1){
            ll sum = 0;
            fr(x, 0, mtrxN - 1){
                sum += a.m[i][x] * b.m[x][j];
                sum %= mod;
            }
            c.m[i][j] = sum;
        }
    }
    return c;
}
mtrx mtrx_pow(mtrx a, ll n){
    mtrx res;
    fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
    n --;
    while(n){
        if(n&1)res = mtrx_mult(res, a);
        a = mtrx_mult(a, a);
        n >>= 1;
    }
    return res;
}
ll _pow(ll a, ll n){
    ll r = 1;
    while(n){
        if(n&1)r = r * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return r;
}
ll div(ll x, ll y, ll md){
    return x * _pow(y, md - 2) % md;
}

ll a[1000001], p[1000001];
ll ans[5001][5001];

int main(){
    ll n, Q;
    cin >> n >> Q;
    if(n <= 5000 && Q <= 5000){
        fr(i, 1, n)cin >> a[i];
        fr(i, 1, n){
            ll mx = -oo, mx_k = 0;
            fr(j, i, n){
                mx = max(mx, a[j]);
                if(mx > a[j])mx_k = max(mx_k, a[j] + mx);
                ans[i][j] = mx_k;
            }
        }
        fr(e, 1, Q){
            ll l, r, k;
            cin >> l >> r >> k;
            if(ans[l][r] <= k)cout << 1 << "\n";
            else cout << 0 << "\n";
        }
        return 0;
    }
    fr(i, 1, n)cin >> a[i];
    fr(i, 1, n - 1){
        p[i] = p[i - 1];
        if(a[i] > a[i + 1])p[i] ++;
    }

    fr(e, 1, Q){
        ll l, r, k;
        cin >> l >> r >> k;
        if(l == r)cout << 1 << "\n";
        else if(p[l] == p[r - 1])cout << 1 << "\n";
        else cout << 0 << "\n";
    }

    return 0;
}
/*
строки +
столбцы -
*/

Compilation message

sortbooks.cpp:17:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(-O3)
                      ^
sortbooks.cpp:18:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 1016 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Correct 7 ms 3320 KB Output is correct
7 Correct 7 ms 3320 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 5 ms 1656 KB Output is correct
10 Correct 6 ms 3320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 1016 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Correct 7 ms 3320 KB Output is correct
7 Correct 7 ms 3320 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 5 ms 1656 KB Output is correct
10 Correct 6 ms 3320 KB Output is correct
11 Correct 28 ms 14332 KB Output is correct
12 Correct 120 ms 111952 KB Output is correct
13 Correct 134 ms 111736 KB Output is correct
14 Correct 151 ms 117368 KB Output is correct
15 Correct 142 ms 117588 KB Output is correct
16 Correct 129 ms 117456 KB Output is correct
17 Correct 94 ms 82808 KB Output is correct
18 Correct 131 ms 117496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 37900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 459 ms 4172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 1016 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Correct 7 ms 3320 KB Output is correct
7 Correct 7 ms 3320 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 5 ms 1656 KB Output is correct
10 Correct 6 ms 3320 KB Output is correct
11 Correct 28 ms 14332 KB Output is correct
12 Correct 120 ms 111952 KB Output is correct
13 Correct 134 ms 111736 KB Output is correct
14 Correct 151 ms 117368 KB Output is correct
15 Correct 142 ms 117588 KB Output is correct
16 Correct 129 ms 117456 KB Output is correct
17 Correct 94 ms 82808 KB Output is correct
18 Correct 131 ms 117496 KB Output is correct
19 Incorrect 1080 ms 10688 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 1016 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Correct 7 ms 3320 KB Output is correct
7 Correct 7 ms 3320 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 5 ms 1656 KB Output is correct
10 Correct 6 ms 3320 KB Output is correct
11 Correct 28 ms 14332 KB Output is correct
12 Correct 120 ms 111952 KB Output is correct
13 Correct 134 ms 111736 KB Output is correct
14 Correct 151 ms 117368 KB Output is correct
15 Correct 142 ms 117588 KB Output is correct
16 Correct 129 ms 117456 KB Output is correct
17 Correct 94 ms 82808 KB Output is correct
18 Correct 131 ms 117496 KB Output is correct
19 Execution timed out 3022 ms 37900 KB Time limit exceeded
20 Halted 0 ms 0 KB -