Submission #578221

# Submission time Handle Problem Language Result Execution time Memory
578221 2022-06-16T08:39:39 Z kingfran1907 Stranded Far From Home (BOI22_island) C++14
0 / 100
3 ms 468 KB
#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());
			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: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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -