제출 #578216

#제출 시각아이디문제언어결과실행 시간메모리
578216kingfran1907Stranded Far From Home (BOI22_island)C++14
0 / 100
3 ms468 KiB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 2010;

int n, m;
int niz[maxn];
vector< int > graph[maxn];
bool bio[maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) 
		scanf("%d", niz+i);
		
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	for (int i = 1; i <= n; i++) {
		int sum = niz[i];
		set< pair<int, int> > s;
		memset(bio, false, sizeof bio);
		
		bio[i] = true;
		for (int tren : graph[i]) {
			s.insert({niz[tren], tren});
		}
		
		while (!s.empty()) {
			int x = s.begin()->second;
			int val = s.begin()->first;
			if (val > sum) break;
			
			s.erase(s.begin());
			bio[x] = true;
			sum += val;
			for (int tren : graph[x]) 
				if (!bio[tren]) s.insert({niz[tren], tren});
		}
		printf("%d", s.empty());
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

island.cpp: In function 'int main()':
island.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
island.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
island.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...