이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#pragma GCC target("popcnt")
#define fi first
#define se second
#define lc id<<1
#define rc id<<1^1
const long long inf = 1e18;
#define nmax 1008
double begintime, endtime;
using namespace std;
inline void CALC_TIME()
{
endtime = clock();
cout << "\nexecution time : " << (endtime - begintime + 1) / 1000 << " s";
}
typedef pair<int, int> pii;
int n, m, u, v, a[nmax];
bool ck[nmax];
vector<int> l[nmax];
void dfs(int x, int pre)
{
ck[x] = true;
for (int tmp : l[x])
if (tmp != pre)
dfs(tmp, x);
}
int main()
{
begintime = clock();
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(ck, false, sizeof(ck));
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
while (m--)
{
cin >> u >> v;
l[u].push_back(v);
l[v].push_back(u);
}
for (int i = 1; i <= n; i++)
if (!ck[i])
dfs(i, i);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |