Submission #26389

# Submission time Handle Problem Language Result Execution time Memory
26389 2017-06-29T17:29:13 Z samir_droubi Pipes (BOI13_pipes) C++14
44.0741 / 100
656 ms 56304 KB
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int mxn=(1e5)+5;
long long c[mxn];
set<pair<int,int> > s;
set<pair<int,int> >gr[mxn];
int ans[mxn*5];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&c[i]);
	for(int i=1;i<=m;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		gr[x].insert({y,i});
		gr[y].insert({x,i});
	}
	if(m>=n)
	{
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;++i)
		s.insert({gr[i].size(),i});
	while(!s.empty())
	{
		int v=s.begin()->second;
		int u=gr[v].begin()->first;
		int in=gr[v].begin()->second;
		s.erase(s.begin());
		gr[u].erase({v,in});
		ans[in]=2*c[v];
		c[u]-=c[v];
	}
	for(int i=1;i<=m;++i)printf("%d\n",ans[i]);
	return 0;
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:13:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%d",&c[i]);
                   ^
pipes.cpp:11:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
pipes.cpp:13:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&c[i]);
                    ^
pipes.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9444 KB Output isn't correct
2 Incorrect 3 ms 9444 KB Output isn't correct
3 Incorrect 0 ms 9576 KB Output isn't correct
4 Incorrect 189 ms 23436 KB Output isn't correct
5 Incorrect 3 ms 9444 KB Output isn't correct
6 Incorrect 3 ms 9444 KB Output isn't correct
7 Incorrect 0 ms 9444 KB Output isn't correct
8 Incorrect 0 ms 9444 KB Output isn't correct
9 Incorrect 0 ms 9576 KB Output isn't correct
10 Incorrect 3 ms 9576 KB Output isn't correct
11 Incorrect 3 ms 9576 KB Output isn't correct
12 Incorrect 0 ms 9576 KB Output isn't correct
13 Incorrect 146 ms 20664 KB Output isn't correct
14 Incorrect 199 ms 22644 KB Output isn't correct
15 Incorrect 206 ms 23568 KB Output isn't correct
16 Incorrect 176 ms 21324 KB Output isn't correct
17 Incorrect 199 ms 23436 KB Output isn't correct
18 Incorrect 209 ms 23568 KB Output isn't correct
19 Incorrect 163 ms 23568 KB Output isn't correct
20 Incorrect 0 ms 9444 KB Output isn't correct
21 Incorrect 0 ms 9576 KB Output isn't correct
22 Incorrect 179 ms 23568 KB Output isn't correct
23 Incorrect 143 ms 20532 KB Output isn't correct
24 Incorrect 209 ms 23568 KB Output isn't correct
25 Incorrect 163 ms 21192 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9444 KB Output isn't correct
2 Incorrect 0 ms 9576 KB Output isn't correct
3 Correct 86 ms 18288 KB Output is correct
4 Correct 86 ms 18816 KB Output is correct
5 Correct 99 ms 18552 KB Output is correct
6 Correct 656 ms 56304 KB Output is correct
7 Incorrect 3 ms 9444 KB Output isn't correct
8 Incorrect 0 ms 9444 KB Output isn't correct
9 Correct 3 ms 9444 KB Output is correct
10 Correct 0 ms 9444 KB Output is correct
11 Correct 3 ms 9444 KB Output is correct
12 Correct 0 ms 9444 KB Output is correct
13 Correct 0 ms 9444 KB Output is correct
14 Incorrect 0 ms 9444 KB Output isn't correct
15 Incorrect 0 ms 9576 KB Output isn't correct
16 Incorrect 0 ms 9576 KB Output isn't correct
17 Correct 0 ms 9576 KB Output is correct
18 Correct 0 ms 9576 KB Output is correct
19 Correct 0 ms 9576 KB Output is correct
20 Correct 0 ms 9576 KB Output is correct
21 Correct 3 ms 9708 KB Output is correct
22 Incorrect 0 ms 9576 KB Output isn't correct
23 Incorrect 63 ms 17100 KB Output isn't correct
24 Incorrect 96 ms 18816 KB Output isn't correct
25 Correct 93 ms 18288 KB Output is correct
26 Correct 99 ms 18816 KB Output is correct
27 Correct 93 ms 18816 KB Output is correct
28 Correct 89 ms 19344 KB Output is correct
29 Correct 503 ms 47064 KB Output is correct
30 Incorrect 93 ms 18684 KB Output isn't correct
31 Incorrect 103 ms 18816 KB Output isn't correct
32 Incorrect 113 ms 18816 KB Output isn't correct
33 Correct 106 ms 18816 KB Output is correct
34 Correct 109 ms 18816 KB Output is correct
35 Correct 106 ms 18816 KB Output is correct
36 Correct 106 ms 18948 KB Output is correct
37 Correct 589 ms 56304 KB Output is correct
38 Incorrect 89 ms 18816 KB Output isn't correct
39 Incorrect 89 ms 18816 KB Output isn't correct
40 Incorrect 103 ms 18816 KB Output isn't correct
41 Correct 76 ms 18816 KB Output is correct
42 Correct 106 ms 18816 KB Output is correct
43 Correct 106 ms 18816 KB Output is correct
44 Correct 119 ms 18552 KB Output is correct
45 Correct 609 ms 51024 KB Output is correct
46 Incorrect 116 ms 18816 KB Output isn't correct
47 Incorrect 79 ms 18816 KB Output isn't correct
48 Incorrect 96 ms 18816 KB Output isn't correct
49 Correct 83 ms 18288 KB Output is correct
50 Correct 83 ms 18816 KB Output is correct
51 Correct 99 ms 18816 KB Output is correct
52 Correct 96 ms 18684 KB Output is correct
53 Correct 583 ms 51816 KB Output is correct
54 Incorrect 103 ms 18684 KB Output isn't correct