답안 #343107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343107 2021-01-03T12:20:22 Z leinad2 Viruses (BOI20_viruses) C++17
11 / 100
1 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]=-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

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);
      |             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 0 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Incorrect 0 ms 364 KB Output isn't correct
22 Halted 0 ms 0 KB -