Submission #870604

# Submission time Handle Problem Language Result Execution time Memory
870604 2023-11-08T13:08:50 Z sleepntsheep Alternating Heights (CCO22_day1problem1) C++17
0 / 25
245 ms 25740 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using i64 = long long;
#define N 3005
#define Q 1000005

int n, k, q, a[N], b[N], d[N], e[N][N][2];
array<int, 3> c[Q];

void upd(int p, int k) { for (;p<N;p+=p&-p) b[p]+=k; }
int qry(int p) { int z = 0; for (;p;p-=p&-p) z += b[p]; return z;}

int main()
{
    ShinLena;
    cin >> n >> k >> q;
    for (int i = (*a = -86, 1); i <= n; ++i) cin >> a[i];
    for (int i = 0; i < q; ++i) cin >> c[i][0] >> c[i][1], c[i][2] = i;
    sort(c, c+q);
    for (int i = n, j = q-1; i; --i)
    {
        if (a[i] == a[i+1]) upd(i+2, 1);
        int x = min(a[i], a[i+1]), y = max(a[i], a[i+1]);
        if (e[x][y][i&1^1]) upd(1+e[x][y][i&1^1], 1);
        e[x][y][i&1] = i+1;
        for (; j >= 0 && c[j][0] >= i; --j)
            d[c[j][2]] = qry(c[j][1]);
    }
    for (int i = 0; i < q; ++i) cout << (d[i] ? "NO\n": "YES\n");


    return 0;
}


Compilation message

Main.cpp: In function 'int main()':
Main.cpp:34:22: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   34 |         if (e[x][y][i&1^1]) upd(1+e[x][y][i&1^1], 1);
      |                     ~^~
Main.cpp:34:44: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   34 |         if (e[x][y][i&1^1]) upd(1+e[x][y][i&1^1], 1);
      |                                           ~^~
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 25740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 245 ms 25736 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 25740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -