Submission #1224360

#TimeUsernameProblemLanguageResultExecution timeMemory
1224360lkaterisInside information (BOI21_servers)C++20
5 / 100
37 ms1604 KiB
#include <iostream>

using namespace std;

int lq[120005];

int main() {

    int N,K;
    scanf("%d%d",&N,&K);

    for(int i=1;i<=N;++i) lq[i] = -1;

    int s=0;
    for(int q=1;q<=N+K-1;++q) {
        char t;
        scanf("\n%c",&t);
        if (t == 'S') {
            s++;
            int a,b;
            scanf("%d%d",&a,&b);
            if (a == 1) lq[b] = s;
            else lq[a] = s;
        }
        else if (t == 'Q') {
            int a,d;
            scanf("%d%d",&a,&d);
            if (a == 1 and lq[d] != -1 or a == d or d == 1 and lq[a] != -1) printf("yes\n");
            else if (lq[d] != -1 and lq[a] != -1 and lq[d] < lq[a]) printf("yes\n");
            else printf("no\n");
        }
        else if (t == 'C') {
            int d;
            scanf("%d",&d);
            if (d == 1) printf("%d\n",s+1);
            else if (lq[d] == -1) printf("1\n");
            else printf("%d\n",s-lq[d]+2);
        }

    }


    return 0;
}

Compilation message (stderr)

servers.cpp: In function 'int main()':
servers.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     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("\n%c",&t);
      |         ~~~~~^~~~~~~~~~~
servers.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |             scanf("%d%d",&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~
servers.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |             scanf("%d%d",&a,&d);
      |             ~~~~~^~~~~~~~~~~~~~
servers.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |             scanf("%d",&d);
      |             ~~~~~^~~~~~~~~
#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...