Submission #26390

# Submission time Handle Problem Language Result Execution time Memory
26390 2017-06-29T17:32:30 Z samir_droubi Pipes (BOI13_pipes) C++14
44.0741 / 100
1000 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());
		s.erase({gr[u].size(),u});
		gr[u].erase({v,in});
		s.insert({gr[u].size(),u});

		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 Execution timed out 1000 ms 9444 KB Execution timed out
2 Execution timed out 1000 ms 9444 KB Execution timed out
3 Execution timed out 1000 ms 9576 KB Execution timed out
4 Execution timed out 1000 ms 23436 KB Execution timed out
5 Execution timed out 1000 ms 9444 KB Execution timed out
6 Execution timed out 1000 ms 9444 KB Execution timed out
7 Execution timed out 1000 ms 9444 KB Execution timed out
8 Execution timed out 1000 ms 9444 KB Execution timed out
9 Execution timed out 1000 ms 9576 KB Execution timed out
10 Execution timed out 1000 ms 9576 KB Execution timed out
11 Execution timed out 1000 ms 9576 KB Execution timed out
12 Execution timed out 1000 ms 9576 KB Execution timed out
13 Execution timed out 1000 ms 20664 KB Execution timed out
14 Execution timed out 1000 ms 22644 KB Execution timed out
15 Execution timed out 1000 ms 23568 KB Execution timed out
16 Execution timed out 1000 ms 21324 KB Execution timed out
17 Execution timed out 1000 ms 23436 KB Execution timed out
18 Execution timed out 1000 ms 23568 KB Execution timed out
19 Execution timed out 1000 ms 23568 KB Execution timed out
20 Execution timed out 1000 ms 9444 KB Execution timed out
21 Execution timed out 1000 ms 9576 KB Execution timed out
22 Execution timed out 1000 ms 23568 KB Execution timed out
23 Execution timed out 1000 ms 20532 KB Execution timed out
24 Execution timed out 1000 ms 23568 KB Execution timed out
25 Execution timed out 1000 ms 21192 KB Execution timed out
# 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 63 ms 18288 KB Output is correct
4 Correct 89 ms 18816 KB Output is correct
5 Correct 93 ms 18552 KB Output is correct
6 Correct 426 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 0 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 3 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 3 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 79 ms 17100 KB Output isn't correct
24 Incorrect 96 ms 18816 KB Output isn't correct
25 Correct 99 ms 18288 KB Output is correct
26 Correct 99 ms 18816 KB Output is correct
27 Correct 83 ms 18816 KB Output is correct
28 Correct 96 ms 19344 KB Output is correct
29 Correct 499 ms 47064 KB Output is correct
30 Incorrect 103 ms 18684 KB Output isn't correct
31 Incorrect 93 ms 18816 KB Output isn't correct
32 Incorrect 99 ms 18816 KB Output isn't correct
33 Correct 93 ms 18816 KB Output is correct
34 Correct 96 ms 18816 KB Output is correct
35 Correct 79 ms 18816 KB Output is correct
36 Correct 93 ms 18948 KB Output is correct
37 Correct 653 ms 56304 KB Output is correct
38 Incorrect 106 ms 18816 KB Output isn't correct
39 Incorrect 93 ms 18816 KB Output isn't correct
40 Incorrect 89 ms 18816 KB Output isn't correct
41 Correct 99 ms 18816 KB Output is correct
42 Correct 93 ms 18816 KB Output is correct
43 Correct 93 ms 18816 KB Output is correct
44 Correct 103 ms 18552 KB Output is correct
45 Correct 616 ms 51024 KB Output is correct
46 Incorrect 106 ms 18816 KB Output isn't correct
47 Incorrect 103 ms 18816 KB Output isn't correct
48 Incorrect 106 ms 18816 KB Output isn't correct
49 Correct 93 ms 18288 KB Output is correct
50 Correct 99 ms 18816 KB Output is correct
51 Correct 93 ms 18816 KB Output is correct
52 Correct 99 ms 18684 KB Output is correct
53 Correct 579 ms 51816 KB Output is correct
54 Incorrect 69 ms 18684 KB Output isn't correct