为啥输出里标准答案里会有一大堆空行?????

P3367 【模板】并查集

hedan @ 2021-05-22 23:45:00

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

const int MAXN = 1e5;

int f[MAXN] = { 0 };
int n = 0, m = 0;

void build(int n)
{
    for (int i = 1; i <= n; i++)
    {
        f[i] = i;
    }
}

int find(int x)
{
    while (x != f[x])
    {
        x = f[x] = f[f[x]];
    }
    return x;
}

void merge(int a, int b)
{
    int fa = find(a), fb = find(b);
    if (fa != fb) f[b] = fa;
}

bool judge(int a, int b)
{
    int fa = find(a), fb = find(b);
    if (fa != fb) return false;
    else return true;
}

void clear(int n)
{
    for (int i = 1; i <= n; i++)
    {
        f[i] = -1;
    }
}

int main()
{
    //freopen("test2.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    cin >> n >> m;
    build(n);
    for (int i = 1; i <= m; i++)
    {
        int op, a, b;
        cin >> op >> a >> b;
        if (op == 1)
        {
            merge(a, b);
            //printf("Merge %d, %d\n", a, b);
        }
        else if (op == 2)
        {
            bool ans = judge(a, b);
            if (ans) cout << "Y" << endl;
            else if (!ans) cout << "N" << endl;
        }
    }

    return 0;
}

用winmerge里试了一下,标准答案中一大堆空行不知道为啥

是第二个标准答案,我把数据下载下来了,因为数据量太大没放在这里

为啥有空行

为啥有空行!!!

为啥有空行!!!

为啥有空行!!!


by SSerxhs @ 2021-05-23 00:02:35

莫名其妙


by cxqghzj @ 2021-05-26 15:38:47

?有空行怎么了


by Morpheuse @ 2021-05-31 20:07:30

有空行应该不影响测评吧


|