Submission #639553

# Submission time Handle Problem Language Result Execution time Memory
639553 2022-09-10T15:29:20 Z Benmath Inside information (BOI21_servers) C++14
0 / 100
224 ms 636 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int brojac=1;
    int par[n+1];
    int par1[n+1];
    for(int i=0;i<=n;i++){
        par[i]=-1;
    }
    for(int k1=0;k1<(n+k-1);k1++){
        char l;
        cin>>l;
        if(l=='S'){
            int x,y;
            cin>>x>>y;
            if(x>y){
                swap(x,y);
            }
            par[y]=x;
            par1[y]=brojac;

            brojac++;
        }else if(l=='Q'){
        int y,x;
        cin>>y>>x;
        if(x==y){
            cout<<"yes"<<endl;
        }else{
		
        map<int,int>mapa;
        int ro=-1;
        int t1=0;
        while(x>0){
                mapa[x]=ro;
            if(par1[x]<ro or par1[x]==-1){

                break;
            }else{
            ro=par1[x];
        x=x/2;
            }
        }
        ro=1e9;
        while(y>0){
            if(mapa[y]!=0){
            	if(mapa[y]<ro){
				
                t1++;
            }
                break;
            }
            if(par1[y]>ro or par1[y]==-1){
                break;
            }else{
            ro=par1[y];
            y=y/2;
            }
        }
        if(t1>0){
            cout<<"yes"<<endl;
        }else{
        cout<<"no"<<endl;
        }
        }
    
        }else{

        }
    }
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:10:9: warning: variable 'par' set but not used [-Wunused-but-set-variable]
   10 |     int par[n+1];
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 218 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 218 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 215 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 215 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 564 KB Output isn't correct
2 Halted 0 ms 0 KB -