fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define endl "\n"
  4. #define F first
  5. #define S second
  6. #define loop(a,n) for(int i=a; i<=n ; i++)
  7. #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
  8. #define NAME ""
  9. using namespace std;
  10. int m, n, negative[100001], zero[100001], a, b, x;
  11. int main(){
  12. ios_base::sync_with_stdio(0);
  13. cin.tie(0);cout.tie(0);
  14. //freopen(NAME".INP","r",stdin);
  15. //freopen(NAME".OUT","w",stdout);
  16. negative[0] = 0;
  17. zero[0] = 0;
  18. cin >> n >> m;
  19. loop(1,n) {
  20. cin >> x;
  21. if(x < 0) {
  22. negative[i] = negative[i - 1] + 1;
  23. } else negative[i] = negative[i - 1];
  24. if(x == 0) {
  25. zero[i] = zero [i - 1] + 1;
  26. } else zero[i] = zero[i - 1];
  27. }
  28. while(m--) {
  29. cin >> a >> b;
  30. if(zero[b] - zero[a - 1] > 0) cout << 0 << endl;
  31. else if ((negative[b] - negative[a - 1]) % 2 == 0) cout << "+" << endl;
  32. else cout << "-" << endl;
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty