QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97352#5672. Connectivity Problemaguo123ML 0ms0kbC++14682b2023-04-16 17:51:052023-04-16 17:51:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-16 17:51:09]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-04-16 17:51:05]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
using namespace std;
typedef long long LL;
const int N=2e5+10;
int n,T;
int ans;
int p[1100];
int find(int x){
    if(p[x]!=x)return p[x]=find(p[x]);
}
int main()
{
    T=1;
    while(T--){
        ans=0;
        cin>>n;
        for(int i=0;i<=1000;i++)p[i]=i;
        for(int i=1;i<=n;i++){
            int a,b;
            cin>>a>>b;
            int pa=find(a),pb=find(b);
            if(pa!=pb){
                puts("N");
                p[pa]=pb;
            }else puts("Y");
        }
       // cout<<ans<<endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

12
3 4
4 9
8 1
2 3
5 6
2 9
5 9
7 3
4 8
5 6
1 8
6 1

output:


result: