답안 #887167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887167 2023-12-13T23:27:52 Z MilosMilutinovic Pipes (BOI13_pipes) C++14
30 / 100
366 ms 131072 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=100100;

int n,m,c[N],res[N];
vector<PII> e[N];

void dfs(int v,int f) {
	for (auto u:e[v]) {
		if (u.fi==f) continue;
		dfs(u.fi,v);
		c[v]-=c[u.fi];
		res[u.se]=c[u.fi];
	}
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n+1) scanf("%d",&c[i]);
	rep(i,1,m+1) {
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].pb(mp(v,i)); e[v].pb(mp(u,i));
	}
	dfs(1,1);
	if (c[1]==0) {
		rep(i,1,m+1) printf("%d\n",2*res[i]);
	} else {
		printf("0\n");
	}
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
pipes.cpp:40:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  rep(i,1,n+1) scanf("%d",&c[i]);
      |               ~~~~~^~~~~~~~~~~~
pipes.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d%d",&u,&v);
      |   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 3060 KB Output is correct
4 Correct 41 ms 9104 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2800 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 36 ms 7872 KB Output is correct
14 Correct 41 ms 8788 KB Output is correct
15 Correct 42 ms 9300 KB Output is correct
16 Correct 35 ms 8136 KB Output is correct
17 Correct 41 ms 9172 KB Output is correct
18 Correct 44 ms 9080 KB Output is correct
19 Correct 48 ms 12368 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2804 KB Output is correct
22 Correct 47 ms 9296 KB Output is correct
23 Correct 38 ms 7764 KB Output is correct
24 Correct 42 ms 9176 KB Output is correct
25 Correct 40 ms 8356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 86 ms 131072 KB Execution killed with signal 9
2 Runtime error 89 ms 131072 KB Execution killed with signal 9
3 Runtime error 184 ms 131072 KB Execution killed with signal 9
4 Runtime error 172 ms 131072 KB Execution killed with signal 9
5 Runtime error 122 ms 131072 KB Execution killed with signal 9
6 Runtime error 203 ms 131072 KB Execution killed with signal 9
7 Runtime error 83 ms 131072 KB Execution killed with signal 9
8 Runtime error 101 ms 131072 KB Execution killed with signal 9
9 Runtime error 83 ms 131072 KB Execution killed with signal 9
10 Runtime error 81 ms 131072 KB Execution killed with signal 9
11 Runtime error 80 ms 131072 KB Execution killed with signal 9
12 Runtime error 78 ms 131072 KB Execution killed with signal 9
13 Runtime error 86 ms 131072 KB Execution killed with signal 9
14 Runtime error 84 ms 131072 KB Execution killed with signal 9
15 Runtime error 88 ms 131072 KB Execution killed with signal 9
16 Runtime error 97 ms 131072 KB Execution killed with signal 9
17 Runtime error 92 ms 131072 KB Execution killed with signal 9
18 Runtime error 94 ms 131072 KB Execution killed with signal 9
19 Runtime error 94 ms 131072 KB Execution killed with signal 9
20 Runtime error 94 ms 131072 KB Execution killed with signal 9
21 Runtime error 83 ms 131072 KB Execution killed with signal 9
22 Runtime error 99 ms 131072 KB Execution killed with signal 9
23 Runtime error 168 ms 131072 KB Execution killed with signal 9
24 Runtime error 216 ms 131072 KB Execution killed with signal 9
25 Runtime error 207 ms 131072 KB Execution killed with signal 9
26 Runtime error 157 ms 131072 KB Execution killed with signal 9
27 Runtime error 151 ms 131072 KB Execution killed with signal 9
28 Runtime error 108 ms 131072 KB Execution killed with signal 9
29 Runtime error 176 ms 131072 KB Execution killed with signal 9
30 Runtime error 247 ms 131072 KB Execution killed with signal 9
31 Runtime error 173 ms 131072 KB Execution killed with signal 9
32 Runtime error 281 ms 131072 KB Execution killed with signal 9
33 Runtime error 162 ms 131072 KB Execution killed with signal 9
34 Runtime error 162 ms 131072 KB Execution killed with signal 9
35 Runtime error 155 ms 131072 KB Execution killed with signal 9
36 Runtime error 113 ms 131072 KB Execution killed with signal 9
37 Runtime error 201 ms 131072 KB Execution killed with signal 9
38 Runtime error 164 ms 131072 KB Execution killed with signal 9
39 Runtime error 366 ms 131072 KB Execution killed with signal 9
40 Runtime error 189 ms 131072 KB Execution killed with signal 9
41 Runtime error 162 ms 131072 KB Execution killed with signal 9
42 Runtime error 164 ms 131072 KB Execution killed with signal 9
43 Runtime error 159 ms 131072 KB Execution killed with signal 9
44 Runtime error 123 ms 131072 KB Execution killed with signal 9
45 Runtime error 176 ms 131072 KB Execution killed with signal 9
46 Runtime error 253 ms 131072 KB Execution killed with signal 9
47 Runtime error 156 ms 131072 KB Execution killed with signal 9
48 Runtime error 171 ms 131072 KB Execution killed with signal 9
49 Runtime error 309 ms 131072 KB Execution killed with signal 9
50 Runtime error 173 ms 131072 KB Execution killed with signal 9
51 Runtime error 192 ms 131072 KB Execution killed with signal 9
52 Runtime error 179 ms 131072 KB Execution killed with signal 9
53 Runtime error 173 ms 131072 KB Execution killed with signal 9
54 Runtime error 163 ms 131072 KB Execution killed with signal 9