답안 #578224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578224 2022-06-16T08:42:39 Z kingfran1907 Stranded Far From Home (BOI22_island) C++14
10 / 100
332 ms 468 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long llint;
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++) {
		llint 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());
			if (bio[x]) continue;
			bio[x] = true;
			sum += val;
			for (int tren : graph[x]) 
				if (!bio[tren]) s.insert({niz[tren], tren});
		}
		printf("%d", s.empty());
	}
	return 0;
}

Compilation message

island.cpp: In function 'int main()':
island.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
island.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
island.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 219 ms 340 KB Output is correct
5 Correct 193 ms 412 KB Output is correct
6 Correct 332 ms 412 KB Output is correct
7 Correct 217 ms 416 KB Output is correct
8 Correct 166 ms 396 KB Output is correct
9 Correct 297 ms 440 KB Output is correct
10 Correct 98 ms 404 KB Output is correct
11 Correct 94 ms 340 KB Output is correct
12 Correct 113 ms 404 KB Output is correct
13 Correct 185 ms 400 KB Output is correct
14 Correct 109 ms 404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 219 ms 340 KB Output is correct
5 Correct 193 ms 412 KB Output is correct
6 Correct 332 ms 412 KB Output is correct
7 Correct 217 ms 416 KB Output is correct
8 Correct 166 ms 396 KB Output is correct
9 Correct 297 ms 440 KB Output is correct
10 Correct 98 ms 404 KB Output is correct
11 Correct 94 ms 340 KB Output is correct
12 Correct 113 ms 404 KB Output is correct
13 Correct 185 ms 400 KB Output is correct
14 Correct 109 ms 404 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Runtime error 1 ms 468 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -