답안 #408721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408721 2021-05-19T14:38:48 Z ly20 Inside information (BOI21_servers) C++17
10 / 100
181 ms 6056 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 121234;
int ini[MAXN], fim[MAXN];
int seg[4 * MAXN];
void update(int cur, int ini, int fim, int a, int b, int val) {
    if(ini > b || fim < a) return;
    if(ini >= a && fim <= b) {
        seg[cur] += val;
        return;
    }
    int m = (ini + fim) / 2;
    int e = 2 * cur, d = 2 * cur + 1;
    update(e, ini, m, a, b, val); update(d, m + 1, fim, a, b, val);
}
int query(int cur, int ini, int fim, int id) {
    if(ini > id || fim < id) return 0;
    if(ini == fim) return seg[cur];
    int m = (ini + fim) / 2;
    int e = 2 * cur, d = 2 * cur + 1;
    return query(e, ini, m, id) + query(d, m + 1, fim, id) + seg[cur];
}
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    k += n - 1;
    for(int i = 1; i <= n; i++) {
        ini[i] = i;
        fim[i] = i;
        update(1, 1, n, ini[i], fim[i], 1);
    }
    for(int i = 0; i < k; i++) {
        char c;
        scanf(" %c", &c);
        if(c == 'S') {
            int a, b;
            scanf("%d %d", &a, &b);
            update(1, 1, n, ini[a], fim[a], -1);
            update(1, 1, n, ini[b], fim[b], -1);
            fim[a] = max(fim[a], fim[b]); fim[b] = fim[a];
            ini[a] = min(ini[a], ini[b]); ini[b] = ini[a];
            update(1, 1, n, ini[a], fim[a], 2);
        }
        else if(c == 'Q') {
            int a, b;
            scanf("%d %d", &a, &b);
            if(b >= ini[a] && b <= fim[a]) printf("yes\n");
            else printf("no\n");
        }
        else {
            int a;
            scanf("%d", &a);
            printf("%d\n", query(1, 1, n, a));
        }
    }
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
servers.cpp:37:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |             scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |             scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:52:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |             scanf("%d", &a);
      |             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 580 KB Output is correct
2 Correct 167 ms 6056 KB Output is correct
3 Correct 176 ms 5876 KB Output is correct
4 Correct 144 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 580 KB Output is correct
2 Correct 167 ms 6056 KB Output is correct
3 Correct 176 ms 5876 KB Output is correct
4 Correct 144 ms 5924 KB Output is correct
5 Correct 46 ms 712 KB Output is correct
6 Correct 172 ms 5440 KB Output is correct
7 Correct 159 ms 5656 KB Output is correct
8 Correct 181 ms 5036 KB Output is correct
9 Correct 177 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 161 ms 5956 KB Output is correct
3 Correct 173 ms 5904 KB Output is correct
4 Correct 142 ms 5824 KB Output is correct
5 Incorrect 37 ms 1476 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 161 ms 5956 KB Output is correct
3 Correct 173 ms 5904 KB Output is correct
4 Correct 142 ms 5824 KB Output is correct
5 Incorrect 37 ms 1476 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -