답안 #899204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899204 2024-01-05T15:28:18 Z AIF_is_carving Inside information (BOI21_servers) C++17
5 / 100
128 ms 9424 KB
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N=2e5+5;
map<int, int> graph;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k; cin>>n>>k;
    graph[1]=1;
    int count=1;

    for(int i=0; i<n+k-1; i++){
        char c; cin>>c;

        if(c=='S'){
            count+=1;
            int u, v; cin>>u>>v;
            graph[max(u,v)]=count;
        }

        else if(c=='Q'){
            int v, chunk; cin>>v>>chunk;
            if(graph.find(v)==graph.end()){
                if(v==chunk) cout<<"yes"<<"\n";
                else cout<<"no"<<"\n";
            }
            else{
                if(graph.find(chunk)==graph.end()) cout<<"no"<<"\n";
                else{
                    if(v==1) cout<<"yes"<<"\n";
                    else if(graph[v]>=graph[chunk]) cout<<"yes"<<"\n";
                    else cout<<"no"<<"\n";
                }
            }
        }

        else{
            int chunk; cin>>chunk;
            if(graph.find(chunk)==graph.end()){
                cout<<1<<"\n";
            }
            else{
                if(chunk==1){
                    int ans=graph.size();
                    cout<<ans<<"\n";
                } 
                else {
                    int ans=graph.size()-graph[chunk]+2;
                    cout<<ans<<"\n";
                }
            }
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 860 KB Output is correct
2 Correct 124 ms 6484 KB Output is correct
3 Correct 128 ms 6484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 860 KB Output is correct
2 Correct 124 ms 6484 KB Output is correct
3 Correct 128 ms 6484 KB Output is correct
4 Correct 21 ms 600 KB Output is correct
5 Correct 115 ms 9424 KB Output is correct
6 Correct 69 ms 8228 KB Output is correct
7 Correct 64 ms 8488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -