# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
637351 |
2022-09-01T13:13:42 Z |
Cyber_Wolf |
Deblo (COCI18_deblo) |
C++14 |
|
22 ms |
8328 KB |
//Problem: Deblo;
//Contest: COCI18 Contest 2 Problem 3
//Link: https://oj.uz/problem/view/COCI18_deblo
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define lg long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);
#define endl \n
#define lbound(x, y) lower_bound(x.begin(), x.end(), y)
#define ubound(x, y) upper_bound(x.begin(), x.end(), y)
#define sortasc(v) sort(v.begin(), v.end())
#define sortdesc(v) sort(v.rbegin(), v.rend())
#define custom_array(a,l, r) int _##a[r-l+1]; int*a=_##a-l;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const lg MOD = 1e9+7, N = 1e3+5, M = 1e7+1, SZ = 1e3+1;
/*
bitset<N> primes;
lg pwrs[N], inv[N];
lg fast_power(lg n, lg k)
{
if(!k) return 1;
if(k&1) return (fast_power(n, k-1)*n)%MOD;
lg x = fast_power(n, k/2)%MOD;
return (x*x)%MOD;
}
void sieve()
{
primes.set();
primes[0] = primes[1] = 0;
for(lg i = 2; i < N; i++)
{
if(!primes[i]) continue;
for(lg j = i*i; j < N; j += i)
{
primes[j] = 0;
}
}
return;
}
struct matrix
{
vector<vector<lg>> con = vector<vector<lg>> (SZ, vector<lg> (SZ));
matrix operator *(const matrix& a)
{
matrix product;
for(int i = 0; i < (lg)con.size(); i++)
{
for(int j = 0; j < (lg)a.con[0].size(); j++)
{
for(int k = 0; k < (lg)a.con.size(); k++)
{
product.con[i][j] = (product.con[i][j]+(con[i][k]*a.con[k][j])%MOD)%MOD;
}
}
}
return product;
}
};
void preprocess(lg x)
{
inv[2e5] = fast_power(x, MOD-2);
for(int i = 2e5-1; i > 1; i--)
{
inv[i] = (inv[i+1]*i)%MOD;
}
pwrs[0] = 1;
for(int i = 1; i <= 2e5; i++)
{
pwrs[i] = (pwrs[i]*i)%MOD;
}
return;
}
*/
vector<lg> v, val(N), adj[N];
lg vis[N][N], x;
lg dfs(lg src, lg par = -1, lg path = 0)
{
path ^= val[src];
// cout << "SRC: " << src << ' ' << path << '\n';
// for(auto it : v)
// {
// cout << it << ' ';
// }
// cout << '\n';
lg ans = 0;
if(!vis[min(x, src)][max(x, src)]) ans += path;
vis[min(x, src)][max(x, src)] = true;
// for(auto it : v)
// {
// ans += (path^it);
// }
for(auto it : adj[src])
{
if(it == par) continue;
//v.push_back(path);
ans += dfs(it, src, path);
//v.pop_back();
}
return ans;
}
int main()
{
fastio;
lg n;
cin >> n;
for(int i = 1; i <= n; i++) cin >> val[i];
for(int i = 0; i < n-1; i++)
{
lg u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
// v.push_back(0);
lg ans = 0;
memset(vis, 0, sizeof(vis));
for(int i = 1; i <= n; i++) x = i, ans += dfs(i);
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8148 KB |
Output is correct |
2 |
Correct |
4 ms |
8148 KB |
Output is correct |
3 |
Correct |
4 ms |
8148 KB |
Output is correct |
4 |
Correct |
21 ms |
8328 KB |
Output is correct |
5 |
Correct |
22 ms |
8312 KB |
Output is correct |
6 |
Runtime error |
5 ms |
852 KB |
Execution killed with signal 11 |
7 |
Runtime error |
4 ms |
852 KB |
Execution killed with signal 11 |
8 |
Runtime error |
3 ms |
884 KB |
Execution killed with signal 11 |
9 |
Runtime error |
3 ms |
852 KB |
Execution killed with signal 11 |
10 |
Runtime error |
3 ms |
916 KB |
Execution killed with signal 11 |