Submission #170458

# Submission time Handle Problem Language Result Execution time Memory
170458 2019-12-25T10:56:20 Z mdn2002 Deblo (COCI18_deblo) C++14
45 / 90
912 ms 65540 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n,a[100005];
long long sm,sum;
vector<int>gr[100005];
map<pair<int,int>,int>m;
void dfs(int x,int p,int org)
{
    sm^=a[x];
    if(m[{org,x}]==0)
    {
        sum+=sm;
        m[{org,x}]=1;
        m[{x,org}]=1;
    }
    for(int i=0;i<gr[x].size();i++)
    {
        int u=gr[x][i];
        if(u==p)continue;
        dfs(u,x,org);
    }
    sm^=a[x];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("lemonade.in","r",stdin);
    //freopen("lemonade.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    for(int i=1;i<=n;i++)dfs(i,0,i);
    cout<<sum;
}

Compilation message

deblo.cpp: In function 'void dfs(int, int, int)':
deblo.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr[x].size();i++)
                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 14 ms 4216 KB Output is correct
4 Correct 605 ms 65528 KB Output is correct
5 Correct 783 ms 65400 KB Output is correct
6 Runtime error 512 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 509 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 364 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 403 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 912 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)