Submission #3459

#TimeUsernameProblemLanguageResultExecution timeMemory
3459Apple_CplusCactus? Not cactus? (kriii1_C)C++98
0 / 1
68 ms11152 KiB
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <algorithm> #include <sstream> #include <set> #include <map> #include <stack> #include <cmath> #include <cstdlib> #include <cstring> #include <string> using namespace std; #define ll long long #define pi pair<int,int> #define pll pair<ll,ll> #define pii pair<int,pi> #define X first #define Y second #define pb push_back #define ab(x) ((x)<0?(-(x)):(x)) #define xx(x) ((x)*(x)) #define mp make_pair #define vi vector<int> #define vll vector<ll> #define vs vector<string> #define vpi vector<pi> #define vpll vector<pll> #define ALL(x) (x).begin(),(x).end() #define Max (1<<30) #define LLMax (1ll<<60) template<class T>string ToString(T t){stringstream s;s<<t;return s.str();} template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;} int n,m; vi v[100005]; bool ck[100005]; int go(int x,int p){ ck[x]=1; int cnt=0; for(int i=0;i<v[x].size();i++){ int t=v[x][i];if(t==p)continue; if(ck[t]){cnt++;continue;} go(t,x); } if(cnt>=2){ cout<<"Not cactus"<<endl; exit(0); } } int main(){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ int s,e;scanf("%d%d",&s,&e); v[s].pb(e);v[e].pb(s); } go(1,-1); cout<<"Cactus"<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...