답안 #408705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408705 2021-05-19T14:14:34 Z ly20 Inside information (BOI21_servers) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 121234;
int v[MAXN];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    k += n - 1;
    for(int i = 1; i <= n; i++) {
        v[i][i] = 1;
    }
    int id = 0;
    v[1] = 0;
    id++;
    for(int i = 0; i < k; i++) {
        char c;
        scanf(" %c", &c);
        if(c == 'S') {
            int a, b;
            scanf("%d %d", &a, &b);
            if(a != 1) swap(a, b);
            v[b] = id++;
        }
        else if(c == 'Q') {
            int a, b;
            scanf("%d %d", &a, &b);
            if(v[a] > v[b]) printf("yes\n");
            else printf("no\n");
        }
        else {
            int a;
            scanf("%d", &a);
            printf("%d\n", id - v[a]);
        }
    }
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:10:13: error: invalid types 'int[int]' for array subscript
   10 |         v[i][i] = 1;
      |             ^
servers.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
servers.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |             scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
servers.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             scanf("%d", &a);
      |             ~~~~~^~~~~~~~~~