Submission #343101

# Submission time Handle Problem Language Result Execution time Memory
343101 2021-01-03T12:17:50 Z leinad2 Viruses (BOI20_viruses) C++17
0 / 100
700 ms 364 KB
#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]=9e18;
    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]==9e18)goto w;
                    p+=dp[b];
                }
                dp[i]=min(dp[i], p);
                w:;
            }
        }
    }
    for(i=2;i<g;i++)
    {
      if(dp[i]==9e18)for(i=0;;i++);
        printf("NO %d\n", dp[i]);
    }
}

Compilation message

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:42:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |       if(dp[i]==9e18)for(i=0;;i++);
      |                      ^~~
Viruses.cpp:43:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |         printf("NO %d\n", dp[i]);
      |         ^~~~~~
Viruses.cpp:43:21: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   43 |         printf("NO %d\n", dp[i]);
      |                    ~^     ~~~~~
      |                     |         |
      |                     int       long long int
      |                    %lld
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 time Memory Grader output
1 Execution timed out 1095 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -