Submission #1081276

#TimeUsernameProblemLanguageResultExecution timeMemory
1081276HienTDFish 3 (JOI24_fish3)C++14
0 / 100
2056 ms5972 KiB
#include <bits/stdc++.h>
using namespace std;

#define                  fi  first
#define                  se  second
#define                TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define              ALL(v)  (v).begin(), (v).end()
#define             MASK(i)  (1LL << (i))
#define           BIT(x, i)  (((x) >> (i)) & 1)
#define           REP(i, v) for( __typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define           F0R(i, n)  for(int i = 0, _n = (n); i < _n; ++ i)
#define          F0RD(i, n)  for(int i = (n); i > 0; -- i)
#define        FOR(i, a, b)  for(int i = (a), _b = (b); i < _b; ++ i)
#define       FORD(i, b, a) for(int i = (b), _a = (a); i > _a; -- i)
#define       FORE(i, a, b)  for(int i = (a), _b = (b); i <= _b; ++ i)
#define      FORDE(i, b, a)  for(int i = (b), _a = (a); i >= _a; -- i)
#define  __builtin_popcount  __builtin_popcountll

#define mxN 300010
#define LOG 19

const string NAME = "BAITAP";

int N, Q;
long long D;
vector<long long> A(mxN);

void init(void){
    cin >> N >> D;
    FORE(i, 1, N) cin >> A[i];
}

void process(void){
    cin >> Q;
    FORE(i, 1, Q){
        int l, r;
        cin >> l >> r;
        bool chk = false;
        bool ans = true;
        FORE(j, l, r){
            if(A[j] >= 1) chk = true;
            else if(A[j] == 0 && chk == true){
                ans = false;
            }
        }
        cout << (ans == true ? 0 : -1) << '\n';
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    #ifdef LOCAL
        freopen((NAME + ".INP").c_str(), "r", stdin);
        freopen((NAME + ".OUT").c_str(), "w", stdout);
    #endif // LOCAL

    init();
    process();

    cerr << "\nTime elapsed AC: " << TIME << "s.\n";

    return 0;
}
#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...