QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114279 | #5672. Connectivity Problem | Thirvin# | WA | 1ms | 3528kb | C++14 | 936b | 2023-06-21 22:20:51 | 2023-06-21 22:20:54 |
Judging History
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'