Submission #672071

# Submission time Handle Problem Language Result Execution time Memory
672071 2022-12-14T16:53:09 Z LittleCube Stranded Far From Home (BOI22_island) C++14
10 / 100
353 ms 624 KB
#include <bits/stdc++.h>
#define ll long long 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

int N, M, s[2005], vis[2005];
vector<int> E[2005];


signed main()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		cin >> s[i];
	for(int i = 1; i <= M; i++)
	{
		int u, v;
		cin >> u >> v;
		E[u].emplace_back(v);
		E[v].emplace_back(u);
	}	
	for(int i = 1; i <= N; i++)
	{
		priority_queue<pii, vector<pii>, greater<pii>> pq;
		ll sum = 0, acc = 0;
		for(int i = 1; i <= N; i++)
			vis[i] = 0;
		vis[i] = 1;
		pq.push(pii(s[i], i));
		while(!pq.empty())
		{
			auto [d, u] = pq.top();
			pq.pop();
			if(sum >= d || u == i)
			{
				acc++;
				sum += d;
			}
			for(int v : E[u])
				if(!vis[v])
				{	
					vis[v] = 1;
					pq.push(pii(s[v], v));
				}
		}
		cout << (acc == N ? 1 : 0);
	}
	cout << '\n';
}

Compilation message

island.cpp: In function 'int main()':
island.cpp:35:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |    auto [d, u] = pq.top();
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 287 ms 444 KB Output is correct
5 Correct 326 ms 448 KB Output is correct
6 Correct 243 ms 428 KB Output is correct
7 Correct 296 ms 340 KB Output is correct
8 Correct 190 ms 340 KB Output is correct
9 Correct 280 ms 468 KB Output is correct
10 Correct 128 ms 448 KB Output is correct
11 Correct 119 ms 468 KB Output is correct
12 Correct 158 ms 444 KB Output is correct
13 Correct 140 ms 432 KB Output is correct
14 Correct 353 ms 428 KB Output is correct
# 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 Runtime error 3 ms 596 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 2 ms 624 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 287 ms 444 KB Output is correct
5 Correct 326 ms 448 KB Output is correct
6 Correct 243 ms 428 KB Output is correct
7 Correct 296 ms 340 KB Output is correct
8 Correct 190 ms 340 KB Output is correct
9 Correct 280 ms 468 KB Output is correct
10 Correct 128 ms 448 KB Output is correct
11 Correct 119 ms 468 KB Output is correct
12 Correct 158 ms 444 KB Output is correct
13 Correct 140 ms 432 KB Output is correct
14 Correct 353 ms 428 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Runtime error 3 ms 596 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -