Submission #170923

# Submission time Handle Problem Language Result Execution time Memory
170923 2019-12-26T17:55:48 Z MatesV13 Deblo (COCI18_deblo) C++11
45 / 90
16 ms 1528 KB
#include <bits/stdc++.h>
using namespace std;
long long n, val[1005], a, b, ans;
vector<int> c[1005];
bool v[1005][1005];
void dfs(int poc, int kraj, long long sol){
	sol^=val[kraj]; ans+=sol; v[poc][kraj]=1;
	for (int i=0; i<c[kraj].size(); i++){
		if (!v[poc][c[kraj][i]])
			dfs(poc, c[kraj][i], sol);
	}
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	cin >> n; for (int i=1; i<=n; i++) cin >> val[i];
	for (int i=1; i<n; i++){
		cin >> a >> b;
		c[a].push_back(b);
		c[b].push_back(a);
	}
	for (int i=1; i<=n; i++){dfs(i, i, 0LL); ans+=val[i];}
	cout << ans/2;
return 0;
}

Compilation message

deblo.cpp: In function 'void dfs(int, int, long long int)':
deblo.cpp:8:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<c[kraj].size(); i++){
                ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 15 ms 1528 KB Output is correct
5 Correct 16 ms 1400 KB Output is correct
6 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)