답안 #284629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284629 2020-08-27T18:44:48 Z ScarletS Pipes (BOI13_pipes) C++17
30 / 100
1000 ms 131076 KB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
#define pii pair<int,int>
using namespace std;

const int MAXN = 100001;
vector<pii> edges[MAXN];
int score[MAXN];
ll cur[MAXN];
int ans[5*MAXN];

void dfs(int c, int p, int x)
{
    for (pii i : edges[c])
        if (i.first != p)
        {
            dfs(i.first, c, i.second);
            cur[c]+=ans[i.second];
        }
    if (c!=1)
    {
        ans[x]=score[c]-cur[c];
        cur[c]=score[c];
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,u,v;
    cin>>n>>m;
    for (int i = 1; i <= n; ++i)
        cin>>score[i];
    for (int i = 0; i < m; ++i)
    {
        cin>>u>>v;
        edges[u].push_back({v,i});
        edges[v].push_back({u,i});
    }
    dfs(1,0,0);
    if (score[1]!=cur[1])
    {
        cout<<"0\n";
        return 0;
    }
    for (int i=0;i<m;++i)
        cout<<ans[i]*2<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2816 KB Output is correct
4 Correct 67 ms 9976 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2816 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 2 ms 2816 KB Output is correct
12 Correct 2 ms 2816 KB Output is correct
13 Correct 52 ms 8568 KB Output is correct
14 Correct 62 ms 9592 KB Output is correct
15 Correct 72 ms 10112 KB Output is correct
16 Correct 56 ms 8916 KB Output is correct
17 Correct 66 ms 9976 KB Output is correct
18 Correct 70 ms 10104 KB Output is correct
19 Correct 83 ms 13356 KB Output is correct
20 Correct 3 ms 2688 KB Output is correct
21 Correct 2 ms 2816 KB Output is correct
22 Correct 75 ms 9976 KB Output is correct
23 Correct 61 ms 8440 KB Output is correct
24 Correct 83 ms 10060 KB Output is correct
25 Correct 53 ms 8824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 97 ms 131076 KB Execution killed with signal 9
2 Runtime error 96 ms 131072 KB Execution killed with signal 9
3 Runtime error 456 ms 131076 KB Execution killed with signal 9
4 Runtime error 352 ms 131076 KB Execution killed with signal 9
5 Runtime error 166 ms 131076 KB Execution killed with signal 9
6 Runtime error 328 ms 131076 KB Execution killed with signal 9
7 Runtime error 97 ms 131076 KB Execution killed with signal 9
8 Runtime error 143 ms 131076 KB Execution killed with signal 9
9 Runtime error 95 ms 131076 KB Execution killed with signal 9
10 Runtime error 96 ms 131076 KB Execution killed with signal 9
11 Runtime error 92 ms 131076 KB Execution killed with signal 9
12 Runtime error 86 ms 131076 KB Execution killed with signal 9
13 Runtime error 86 ms 131076 KB Execution killed with signal 9
14 Runtime error 97 ms 131076 KB Execution killed with signal 9
15 Runtime error 115 ms 131076 KB Execution killed with signal 9
16 Runtime error 120 ms 131076 KB Execution killed with signal 9
17 Runtime error 109 ms 131076 KB Execution killed with signal 9
18 Runtime error 109 ms 131072 KB Execution killed with signal 9
19 Runtime error 100 ms 131076 KB Execution killed with signal 9
20 Runtime error 90 ms 131076 KB Execution killed with signal 9
21 Runtime error 86 ms 131076 KB Execution killed with signal 9
22 Runtime error 99 ms 131076 KB Execution killed with signal 9
23 Runtime error 273 ms 131076 KB Execution killed with signal 9
24 Runtime error 432 ms 131072 KB Execution killed with signal 9
25 Runtime error 419 ms 131076 KB Execution killed with signal 9
26 Runtime error 312 ms 131076 KB Execution killed with signal 9
27 Runtime error 240 ms 131076 KB Execution killed with signal 9
28 Runtime error 132 ms 131076 KB Execution killed with signal 9
29 Runtime error 244 ms 131076 KB Execution killed with signal 9
30 Runtime error 551 ms 131072 KB Execution killed with signal 9
31 Runtime error 314 ms 131072 KB Execution killed with signal 9
32 Runtime error 781 ms 131076 KB Execution killed with signal 9
33 Runtime error 320 ms 131076 KB Execution killed with signal 9
34 Runtime error 235 ms 131076 KB Execution killed with signal 9
35 Runtime error 399 ms 131076 KB Execution killed with signal 9
36 Runtime error 153 ms 131072 KB Execution killed with signal 9
37 Runtime error 325 ms 131076 KB Execution killed with signal 9
38 Runtime error 388 ms 131076 KB Execution killed with signal 9
39 Execution timed out 1096 ms 122260 KB Time limit exceeded
40 Runtime error 387 ms 131076 KB Execution killed with signal 9
41 Runtime error 330 ms 131076 KB Execution killed with signal 9
42 Runtime error 327 ms 131076 KB Execution killed with signal 9
43 Runtime error 355 ms 131076 KB Execution killed with signal 9
44 Runtime error 162 ms 131072 KB Execution killed with signal 9
45 Runtime error 313 ms 131076 KB Execution killed with signal 9
46 Runtime error 656 ms 131076 KB Execution killed with signal 9
47 Runtime error 313 ms 131076 KB Execution killed with signal 9
48 Runtime error 374 ms 131076 KB Execution killed with signal 9
49 Runtime error 862 ms 131072 KB Execution killed with signal 9
50 Runtime error 412 ms 131076 KB Execution killed with signal 9
51 Runtime error 445 ms 131076 KB Execution killed with signal 9
52 Runtime error 247 ms 131076 KB Execution killed with signal 9
53 Runtime error 266 ms 131076 KB Execution killed with signal 9
54 Runtime error 448 ms 131076 KB Execution killed with signal 9