답안 #870606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870606 2023-11-08T13:12:46 Z sleepntsheep Alternating Heights (CCO22_day1problem1) C++17
0 / 25
240 ms 25684 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 = a[i], y = a[i+1];
        if (e[x][y][i&1^1]) upd(e[x][y][i&1^1], 1);
        if (e[y][x][i&1]) upd(e[y][x][i&1], 1);
        e[x][y][i&1] = i+1;
        e[y][x][i&1^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(e[x][y][i&1^1], 1);
      |                     ~^~
Main.cpp:34:42: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   34 |         if (e[x][y][i&1^1]) upd(e[x][y][i&1^1], 1);
      |                                         ~^~
Main.cpp:37:18: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   37 |         e[y][x][i&1^1] = i+1;
      |                 ~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 235 ms 25684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 240 ms 25684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 8 ms 19292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 235 ms 25684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -