Submission #170918

# Submission time Handle Problem Language Result Execution time Memory
170918 2019-12-26T17:48:40 Z MatesV13 Deblo (COCI18_deblo) C++11
18 / 90
15 ms 1400 KB
#include <bits/stdc++.h>
using namespace std;
int n, val[1005], a, b, ans;
vector<int> c[1005];
bool v[1005][1005];
void dfs(int poc, int kraj, int 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, 0); ans+=val[i];}
	cout << ans/2;
return 0;
}

Compilation message

deblo.cpp: In function 'void dfs(int, int, 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 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 504 KB Output isn't correct
4 Incorrect 15 ms 1400 KB Output isn't correct
5 Incorrect 15 ms 1400 KB Output isn't 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 632 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 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)