답안 #870603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870603 2023-11-08T13:07:59 Z sleepntsheep Alternating Heights (CCO22_day1problem1) C++17
0 / 25
247 ms 35184 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+1, 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;
        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);
      |                                           ~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 35184 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 247 ms 33332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 5 ms 10000 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 35184 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -