답안 #1102060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102060 2024-10-17T11:23:19 Z razivo Viruses (BOI20_viruses) C++14
0 / 100
1 ms 348 KB
#include <iostream>
#include <vector>
#include <climits>
typedef long long ll;
using namespace std;
int main() {
    ll g,n,m; cin>>g>>n>>m;
    vector<vector<vector<ll>>> mut(g);
    vector<vector<pair<ll,vector<ll>>>> tran(g);
    for (ll i = 0; i < n; ++i) {
        ll x,y; cin>>x>>y;
        ll t = mut[x].size();
        mut[x].push_back({});
        for (ll j = 0; j < y; ++j) {
            ll u; cin>>u;
            mut[x][t].push_back(u);
        }
        for (ll j = 0; j < y; ++j) {
            tran[mut[x][t][j]].push_back({x,mut[x][t]});
        }
    }
    vector<vector<ll>> anti(m);
    for (ll i = 0; i < m; ++i) {
        ll l; cin>>l;
        for (ll j = 0; j < l; ++j) {
            ll u; cin>>u;
            anti[i].push_back(u);
        }
    }
    if(m==0) {
        vector<ll> len(g,LONG_MAX);
        len[0]=1;
        len[1]=1;
        vector<bool> vis(g,false);
        while(true) {
            int cur = -1;
            for (int i = 0; i < g; ++i) {
                if(!vis[i]) cur=i;
            }
            if(cur==-1) break;

            for(auto [a,b]:tran[cur]) {
                ll curlength= 0;
                for(ll u: b) {
                    if(len[u]==LONG_MAX||curlength==LONG_MAX)curlength=LONG_MAX;
                    else curlength+=len[u];
                }
                len[a]=min(len[a],curlength);
            }
            vis[cur] = true;
        }
        for (long long i = 2; i < g; ++i) {
            if(len[i]==LONG_MAX) cout<<"YES"<<endl;
            else cout<<"NO " << len[i]<<endl;
        }
    }
}

Compilation message

Viruses.cpp: In function 'int main()':
Viruses.cpp:42:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |             for(auto [a,b]:tran[cur]) {
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -