fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define scl(x) scanf("%lld",&x)
  5. #define sc(x) scanf("%d",&x)
  6. #define ll long long
  7. #define lop(i,n) for(int i=0;i<n;++i)
  8. typedef pair<int, int> ii;
  9. typedef pair<ll, ll> pll;
  10.  
  11. const int N=805;
  12. double mx[N][N];
  13. int n,m;
  14.  
  15. int main(){
  16. ios_base::sync_with_stdio(false);
  17. cin.tie(nullptr);
  18. cin>>n>>m;
  19. //sc(n),sc(m);
  20. int x = -1e9;
  21. for(int i=0;i<n;i++)
  22. for(int j=0;j<n;j++)
  23. mx[i][j]=x;
  24. int a,b;
  25. double c;
  26. lop(i,m){
  27. //sc(a);sc(b);
  28. //scanf("%lf",&c);
  29. cin>>a>>b>>c;
  30. --a;
  31. --b;
  32. mx[a][b]=fmax(mx[a][b],log(c));
  33. }
  34. for(int k = 0 ; k<n ; ++k)
  35. for(int i = 0 ; i<n ; ++i)
  36. for(int j = 0 ; j<n ; ++j)
  37. mx[i][j]=fmax(mx[i][j],mx[i][k]+mx[k][j]);
  38. for(int i=0;i<n;i++)
  39. if(mx[i][i]>0)
  40. return puts("inadmissible");
  41. puts("admissible");
  42.  
  43. }
Success #stdin #stdout 0s 4420KB
stdin
Standard input is empty
stdout
admissible