1#include <cstdio>2#include <iostream>3#include <string.h>4#include <algorithm>5#include <math.h>6#include <stdbool.h>7#include <map>8#include <stack>9#include <queue>Ten#include <vector> One using namespacestd; A #defineCLR (x, y) memset (x,y,sizeof (×)) - #defineSQR (x) ((x) * (x)) - #defineRep (i,a,b) for (int i= (a); i<= (b); i++) the #defineLL Long Long - #defineINF 0x3f3f3f3f - #defineA First - #defineB Second + Const intn= +; -vector<int>G[n]; + A intN,m,color[n]; at voidInit () - { -CLR (color,0); - } - - BOOLDfsintVintc) in { -color[v]=C; to for(intI=0; I<g[v].size (); i++) { + if(COLOR[G[V][I]]==C)return false; - if(!color[g[v][i]] &&!dfs (g[v][i],-c))return false; the } * return true; $ }Panax Notoginseng - voidSolve () the { + for(intI=0; i<n;i++) { A if(!Color[i]) { the if(!dfs (I,1)) { +printf"no\n"); - return; $ } $ } - } -printf"yes\n"); the } - Wuyi the intMain () - { Wu intx, y; - About init (); $scanf"%d%d",&n,&m); - for(intI=0; i<m;i++) { -scanf"%d%d",&x,&y); - g[x].push_back (y); A } + the solve (); - $ return 0; the}
Two-Part chart determination