답안 #343090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343090 2021-01-03T12:11:50 Z leinad2 Viruses (BOI20_viruses) C++17
0 / 100
1 ms 364 KB
#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++)
    {
        printf("NO %d\n", dp[i]);
    }
}

Compilation message

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: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);
      |             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -