feat: new graph problem formatted.
This commit is contained in:
52
rede-anel-estelar/src/ac.cpp
Normal file
52
rede-anel-estelar/src/ac.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// https://codeforces.com/problemset/problem/104/C
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
using vi = vector<int>;
|
||||
using ll = long long;
|
||||
|
||||
const int MAXN = 110;
|
||||
vector<vi> g(MAXN);
|
||||
bitset<MAXN> vis;
|
||||
|
||||
void dfs(int x){
|
||||
vis[x]=1;
|
||||
for(auto n: g[x]) if(!vis[n]) dfs(n);
|
||||
}
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n, m; cin >> n >> m;
|
||||
|
||||
for (int i=0;i<m;i++){
|
||||
int u,v; cin>>u>>v;
|
||||
g[u].push_back(v);
|
||||
g[v].push_back(u);
|
||||
}
|
||||
|
||||
if (n != m) {
|
||||
cout << "OFFLINE" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
vis.reset();
|
||||
dfs(1);
|
||||
for (int i=1;i<=n;i++){
|
||||
if (!vis[i]) {
|
||||
cout << "OFFLINE" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "ONLINE" << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0); cout.tie(0);
|
||||
solve();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user