답안 #498176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498176 2021-12-24T13:58:18 Z kingline Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
1388 ms 98256 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int M = 305;
const int mod = 1e9 + 7;

int n, m, a[N], L[N], t[4 * N], ans[N];
vector < pair < int, pii > > pos[N];

void update(int v, int l, int r, int pos, int val) {
    if(l == r) {
        t[v] = max(t[v], val);
        return;
    }
    int md = (l + r) / 2;
    if(pos <= md) update(v * 2, l, md, pos, val);
    else update(v * 2 + 1, md + 1, r, pos, val);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int get(int v, int l, int r, int tl, int tr) {
    if(tl <= l && r <= tr) {
        return t[v];
    }
    if(r < tl || tr < l) return -1;
    int md = (l + r) / 2;
    return max(get(v * 2, l, md, tl, tr),
               get(v * 2 + 1, md + 1, r, tl, tr));
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //file("pieaters");
    cin >> n >> m;
    stack < pii > st;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        while(st.size() && (st.top()).first < a[i]) {
            st.pop();
        }
        if(st.size()) L[i] = (st.top()).second;
        st.push({a[i], i});
    }
    for(int i = 1; i <= m; i++) {
        int l, r, k;
        cin >> l >> r >> k;
        pos[r].pb({l, {k, i}});
    }
    for(int i = 1; i <= n; i++) {
        if(L[i] > 0) update(1, 1, n, L[i], a[i] + a[L[i]]);
        for(int j = 0; j < pos[i].size(); j++) {
            int lef = pos[i][j].first, kk = pos[i][j].second.first, query = pos[i][j].second.second;
            if(get(1, 1, n, lef, i) > kk) {
                ans[query] = 0;
            } else {
                ans[query] = 1;
            }
        }
    }
    for(int i = 1; i <= m; i++) {
        cout << ans[i] << endl;
    }
}













Compilation message

sortbooks.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main() {
      | ^~~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:73:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for(int j = 0; j < pos[i].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 13 ms 23756 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 17 ms 23756 KB Output is correct
7 Correct 18 ms 23788 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 13 ms 23932 KB Output is correct
10 Incorrect 14 ms 23840 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 13 ms 23756 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 17 ms 23756 KB Output is correct
7 Correct 18 ms 23788 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 13 ms 23932 KB Output is correct
10 Incorrect 14 ms 23840 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1346 ms 98256 KB Output is correct
2 Correct 1358 ms 98216 KB Output is correct
3 Correct 1388 ms 98120 KB Output is correct
4 Correct 1366 ms 98112 KB Output is correct
5 Incorrect 1274 ms 97216 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 31636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 13 ms 23756 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 17 ms 23756 KB Output is correct
7 Correct 18 ms 23788 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 13 ms 23932 KB Output is correct
10 Incorrect 14 ms 23840 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 13 ms 23756 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 17 ms 23756 KB Output is correct
7 Correct 18 ms 23788 KB Output is correct
8 Correct 15 ms 23756 KB Output is correct
9 Correct 13 ms 23932 KB Output is correct
10 Incorrect 14 ms 23840 KB Output isn't correct