답안 #743261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743261 2023-05-17T09:17:00 Z salmon Viruses (BOI20_viruses) C++14
11 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
int G,N,M;
vector<pair<int,vector<int>>> lst;
int cont[110];
//vector<vector<int>> bask[110];
vector<int> listener[110];
unsigned long long int d[110];
priority_queue<pair<unsigned long long int, int>,vector<pair<unsigned long long int, int>>,greater<pair<unsigned long long int, int>>> pq;
int n,h,in;

int main(){
    scanf(" %d",&G);
    scanf(" %d",&N);
    scanf(" %d",&M);
    
    for(int i = 0; i < 105; i++){
		cont[i] = 0;
		d[i] = 0;
	}

    for(int i = 0; i < N; i++){
		scanf(" %d",&in);
		
		vector<int> v;
		
        scanf(" %d",&n);
        for(int i = 0; i < G; i++){
            v.push_back(0);
        }

        for(int j = 0; j < n; j++){
            scanf(" %d",&h);
            if(v[h] == 0){
				listener[h].push_back(i);
				cont[i]++;
			}
            v[h]++;
        }
        
        lst.push_back(make_pair(in,v));
    }
	
	pq.push(make_pair(1,0));
	pq.push(make_pair(1,1));
	while(!pq.empty()){
		int i = pq.top().second;
		
		if(d[i] != 0){
			pq.pop();
			continue;
		}
		
		d[i] = pq.top().first;
		pq.pop();
		
		while(!listener[i].empty()){
			cont[listener[i][listener[i].size() - 1]]--;
			
			if(cont[listener[i][listener[i].size() - 1]] == 0){
				int j = listener[i][listener[i].size() - 1];
				unsigned long long int V = 0;
				
				for(int i = 0; i < G; i++){
					V = V + d[i] * lst[j].second[i];
				}
				
				pq.push(make_pair(V,lst[j].first));
			}
			
			listener[i].pop_back();
		}
	}
	
	for(int i = 2; i < G; i++){
		if(d[i] == 0){
			printf("YES\n");
		}
		else{
			printf("NO %llu\n",d[i]);
		}
	}
	
}

Compilation message

Viruses.cpp: In function 'int main()':
Viruses.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf(" %d",&G);
      |     ~~~~~^~~~~~~~~~
Viruses.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
Viruses.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf(" %d",&M);
      |     ~~~~~^~~~~~~~~~
Viruses.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf(" %d",&in);
      |   ~~~~~^~~~~~~~~~~
Viruses.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf(" %d",&n);
      |         ~~~~~^~~~~~~~~~
Viruses.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf(" %d",&h);
      |             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 1 ms 232 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -