Submission #1224508

#TimeUsernameProblemLanguageResultExecution timeMemory
1224508JerInside information (BOI21_servers)C++20
5 / 100
39 ms1696 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 120005;
int n, k;
int cnt[MAXN];
pair<int, int> rang[MAXN];

void share(int a, int b){
    int la = rang[a].first, ra = rang[a].second;
    int lb = rang[b].first, rb = rang[b].second;
    int l = min(la, lb), r = max(ra, rb);

    rang[a] = rang[b] = {l, r};
}

int main(){
    scanf("%d%d", &n, &k);

    for (int i = 1; i <= n; i++)
        rang[i] = {i, i};

    char t;
    int a, b, c;
    int passed = 0;
    for (int z = 0; z < n + k - 1; z++)
    {
        scanf(" %c", &t);

        if (t == 'S')
        {
            scanf("%d%d", &a, &b);
            share(min(a, b), max(a, b));
        }

        if (t == 'Q')
        {
            scanf("%d%d", &a, &b);
            printf("%s\n", (b >= rang[a].first and b <= rang[a].second) ? "yes" : "no");
        }

        if (t == 'C')
        {
            scanf("%d", &c);
            printf("0\n");
        }
    }

    return 0;
}

Compilation message (stderr)

servers.cpp: In function 'int main()':
servers.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf(" %c", &t);
      |         ~~~~~^~~~~~~~~~~
servers.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf("%d%d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |             scanf("%d%d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:45:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |             scanf("%d", &c);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...