Submission #43030276


Source Code Expand

#include <bits/stdc++.h>
#define rg register
#define pc putchar
#define gc getchar
#define pf printf
#define space pc(' ')
#define enter pc('\n')
#define me(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define FOR(i,k,t,p) for(rg int i(k) ; i <= t ; i += p)
#define ROF(i,k,t,p) for(rg int i(k) ; i >= t ; i -= p)
using namespace std ;
bool s_gnd ;
inline void read(){}
template<typename T,typename ...T_>
inline void read(T &x,T_&...p)
{
    x = 0 ;rg int f(0) ; rg char c(gc()) ;
    while(!isdigit(c)) f |= (c=='-'),c = gc() ;
    while(isdigit(c)) x = (x<<1)+(x<<3)+(c^48),c = gc() ;
    x = (f?-x:x) ;
    read(p...);
}
int stk[30],tp ;
inline void print(){}
template<typename T,typename ...T_>
inline void print(T x,T_...p)
{
    if(x < 0) pc('-'),x = -x ;
    do stk[++tp] = x%10,x /= 10 ; while(x) ;
    while(tp) pc(stk[tp--]^48) ; space ;
    print(p...) ;
}
const int N = 2e5+5 ;
int n,m,T,res,g ;
int vis[N],to[N],dep[N] ;
vector<int>a[N],b[N] ;
bool S_GND ;
void Dfs1(int x)
{
    to[x] = 1 ;
    for(auto v:b[x]) if(!to[v]) Dfs1(v) ;
}
void Dfs2(int x)
{
    vis[x] = 1 ;
    for(auto v:a[x])
    {
        if(!to[v]) continue ;
        if(vis[v]) 
        {
            if(!g) g = abs(dep[x]+1-dep[v]) ;
            else g = __gcd(g,abs(dep[x]+1-dep[v])) ;
        }
        else dep[v] = dep[x]+1,Dfs2(v) ;
    }
}
void Solve()
{
    read(n,m),me(vis,0),me(to,0),me(dep,0) ;
    FOR(i,1,n,1) a[i].clear(),b[i].clear() ;
    FOR(i,1,m,1)
    {
        int u,v ; read(u,v) ;
        a[u].pb(v),b[v].pb(u) ;
    }
    g = 0,Dfs1(1),Dfs2(1) ;//,print(g),enter ;
    // FOR(i,1,n,1) print(dep[i]) ; enter ;
    if(!g) {puts("No") ; return ;}
    while(!(g%2)) g /= 2 ;
    while(!(g%5)) g /= 5 ;
    if(g == 1) puts("Yes") ; else puts("No") ;

}
signed main()
{
//cerr<<(double)(&s_gnd-&S_GND)/1024.0/1024.0 ;
//	freopen(".in","r",stdin) ;
//	freopen(".out","w",stdout) ;
    read(T) ; while(T--) Solve() ;
    return 0 ;
}

Submission Info

Submission Time
Task G - Return to 1
User c20210623
Language C++ (GCC 9.2.1)
Score 600
Code Size 2018 Byte
Status AC
Exec Time 1512 ms
Memory 24456 KiB

Compile Error

./Main.cpp: In function ‘void read(T&, T_& ...)’:
./Main.cpp:18:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     x = 0 ;rg int f(0) ; rg char c(gc()) ;
      |                   ^
./Main.cpp:18:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     x = 0 ;rg int f(0) ; rg char c(gc()) ;
      |                                  ^
./Main.cpp: In function ‘void Solve()’:
./Main.cpp:61:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   61 |     FOR(i,1,n,1) a[i].clear(),b[i].clear() ;
      |         ^
./Main.cpp:10:33: note: in definition of macro ‘FOR’
   10 | #define FOR(i,k,t,p) for(rg int i(k) ; i <= t ; i += p)
      |                                 ^
./Main.cpp:62:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   62 |     FOR(i,1,m,1)
      |         ^
./Main.cpp:10:33: note: in definition of macro ‘FOR’
   10 | #define FOR(i,k,t,p) for(rg int i(k) ; i <= t ; i += p)
      |                                 ^
./Main.cpp: In instantiation of ‘void read(T&, T_& ...) [with T = int; T_ = {int}]’:
./Main.cpp:60:13:   required from here
./Main.cpp:18:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     x = 0 ;rg int f(0) ; rg char c(gc()) ;
      |                   ^
./Main.cpp:18:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     x = 0 ;rg int f(0) ; rg char c(gc()) ;
      |                                  ^
./Main.cpp: In instantiation of ‘void read(T&, T_& ...) [with T = int; T_ = {}]’:
./Main.cpp:80:11:   required from here
./Main.cpp:18:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   18 |     x = 0 ;rg int f(0) ; rg char c(gc()) ;
      |                   ^
./Main.cpp:18:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
  ...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 39
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 03_dag_00.txt, 03_dag_01.txt, 03_dag_02.txt, 03_dag_03.txt, 03_dag_04.txt, 03_dag_05.txt, 04_misc_00.txt, 05_killer_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 29 ms 15160 KiB
01_random_00.txt AC 1467 ms 15288 KiB
01_random_01.txt AC 186 ms 15304 KiB
01_random_02.txt AC 45 ms 15556 KiB
01_random_03.txt AC 37 ms 17328 KiB
01_random_04.txt AC 37 ms 17140 KiB
01_random_05.txt AC 1441 ms 15284 KiB
01_random_06.txt AC 194 ms 15304 KiB
01_random_07.txt AC 48 ms 15584 KiB
01_random_08.txt AC 41 ms 17260 KiB
01_random_09.txt AC 96 ms 22340 KiB
01_random_10.txt AC 1512 ms 15096 KiB
01_random_11.txt AC 198 ms 15176 KiB
01_random_12.txt AC 46 ms 15408 KiB
01_random_13.txt AC 36 ms 17368 KiB
01_random_14.txt AC 39 ms 17320 KiB
02_random2_00.txt AC 47 ms 15412 KiB
02_random2_01.txt AC 36 ms 16520 KiB
02_random2_02.txt AC 80 ms 20908 KiB
02_random2_03.txt AC 46 ms 15468 KiB
02_random2_04.txt AC 38 ms 16592 KiB
02_random2_05.txt AC 84 ms 24456 KiB
02_random2_06.txt AC 50 ms 15344 KiB
02_random2_07.txt AC 37 ms 16584 KiB
02_random2_08.txt AC 61 ms 19136 KiB
02_random2_09.txt AC 45 ms 15348 KiB
02_random2_10.txt AC 36 ms 16520 KiB
02_random2_11.txt AC 99 ms 23820 KiB
02_random2_12.txt AC 47 ms 15556 KiB
02_random2_13.txt AC 42 ms 16440 KiB
02_random2_14.txt AC 45 ms 18256 KiB
03_dag_00.txt AC 46 ms 15680 KiB
03_dag_01.txt AC 37 ms 17256 KiB
03_dag_02.txt AC 46 ms 18192 KiB
03_dag_03.txt AC 45 ms 15760 KiB
03_dag_04.txt AC 33 ms 17312 KiB
03_dag_05.txt AC 42 ms 18024 KiB
04_misc_00.txt AC 15 ms 15284 KiB
05_killer_00.txt AC 25 ms 17052 KiB