Submission #343097

#TimeUsernameProblemLanguageResultExecution timeMemory
343097leinad2Viruses (BOI20_viruses)C++17
0 / 100
1095 ms364 KiB
#include<bits/stdc++.h> using namespace std; int n, i, j, k, m, g, a, b, dp[110]; vector<int>v[110], A[110]; int main() { for(scanf("%d %d %d", &g, &n, &m);i++<n;) { scanf("%d %d", &a, &k); v[a].push_back(i); while(k--) { scanf("%d", &b); A[i].push_back(b); } } //bellman-ford dp[0]=dp[1]=1; for(i=2;i<g;i++)dp[i]=1e9; 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]==1e9)goto w; p+=dp[b]; } dp[i]=min(dp[i], p); w:; } } } for(i=2;i<g;i++) { if(dp[i]==1e9)for(i=0;;i++); printf("NO %d\n", dp[i]); } }

Compilation message (stderr)

Viruses.cpp: In function 'int main()':
Viruses.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for(j=0;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~
Viruses.cpp:28:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 for(a=0;a<A[k].size();a++)
      |                         ~^~~~~~~~~~~~
Viruses.cpp:41:21: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |       if(dp[i]==1e9)for(i=0;;i++);
      |                     ^~~
Viruses.cpp:42:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |         printf("NO %d\n", dp[i]);
      |         ^~~~~~
Viruses.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     for(scanf("%d %d %d", &g, &n, &m);i++<n;)
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Viruses.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |         scanf("%d %d", &a, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Viruses.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |             scanf("%d", &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...