Submission #343107

#TimeUsernameProblemLanguageResultExecution timeMemory
343107leinad2Viruses (BOI20_viruses)C++17
11 / 100
1 ms364 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int n, i, j, k, m, g, a, b, dp[110]; vector<int>v[110], A[110]; main() { for(scanf("%lld %lld %lld", &g, &n, &m);i++<n;) { scanf("%lld %lld", &a, &k); v[a].push_back(i); while(k--) { scanf("%lld", &b); A[i].push_back(b); } } //bellman-ford dp[0]=dp[1]=1; for(i=2;i<g;i++)dp[i]=-1; for(int x=0;x<g;x++) { for(i=2;i<g;i++) { for(j=0;j<v[i].size();j++) { int p=0; k=v[i][j]; for(a=0;a<A[k].size();a++) { b=A[k][a]; if(dp[b]==-1)goto w; p+=dp[b]; } if(dp[i]==-1)dp[i]=p; else dp[i]=min(dp[i], p); w:; } } } for(i=2;i<g;i++) { if(dp[i]==-1)puts("YES"); else printf("NO %lld\n", dp[i]); } }

Compilation message (stderr)

Viruses.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      |      ^
Viruses.cpp: In function 'int main()':
Viruses.cpp:25:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(j=0;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~
Viruses.cpp:29:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 for(a=0;a<A[k].size();a++)
      |                         ~^~~~~~~~~~~~
Viruses.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     for(scanf("%lld %lld %lld", &g, &n, &m);i++<n;)
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Viruses.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%lld %lld", &a, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
Viruses.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |             scanf("%lld", &b);
      |             ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...