QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114279#5672. Connectivity ProblemThirvin#WA 1ms3528kbC++14936b2023-06-21 22:20:512023-06-21 22:20:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-21 22:20:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3528kb
  • [2023-06-21 22:20:51]
  • 提交

answer

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int n;
vector<int> table[1005];
int boss[1005];
int find(int i,int j)
{
    int vis[1005] = {0};
    queue<int> bfs;
    vis[i] = 1;
    bfs.push(i);
    while(!bfs.empty())
    {
        vis[bfs.front()] = 1;
        for (auto k:table[bfs.front()])
        {
            if(k == j)
                return 1;
            if(vis[k])
                continue;


            bfs.push(k);
        }
        bfs.pop();
    }
    return 0;
}
int main()
{
    int t;
    cin >> t;
    for (int i = 0; i <= 1000; i++)
        boss[i] = i;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        if(find(a,b) ==1 )
        {
            cout << "Y\n";
        }
        else
        {
            cout << "N";
            table[a].push_back(b);
            table[b].push_back(a);
        }


    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3528kb

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:

NNNNNY
NNNY
Y
Y

result:

wrong answer 1st lines differ - expected: 'N', found: 'NNNNNY'