adityav664's blog

By adityav664, 21 month(s) ago, In English

I have issue in question named as C. Rumor -893C, link :- https://codeforces.com/problemset/problem/893/C. I think that i have understand the questions basic as we have to find number of component in graph with minimum price of component and simply we have to do addition i on them. I have come up with pretty good solution but test case 8 getting fail. can you help me where is the problem lies in my code.

include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int solve(){ ll n,m; cin>>n>>m; ll a[n]; for(ll i=0;i<n;i++) cin>>a[i]; for(ll i=0;i<m;i++){ ll x,y; cin>>x>>y; x--;y--; ll t=min(a[x],a[y]); a[x]=t; a[y]=0; } ll res=0; for(ll i=0;i<n;i++) res+=a[i]; cout<<res<<endl; return 0; }

int main(){ ll t=1; //cin>>t; while(t--) solve(); return 0; }

submission link:- https://codeforces.com/contest/893/submission/167180749. thanks in advance.

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
21 month(s) ago, # |
  Vote: I like it +3 Vote: I do not like it

Format your code for christsake, no one will read that

»
21 month(s) ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

The idea is correct but your implementation seems wrong to me.

You have just considered every edge and made one of them equal to min(first, second) while making the other one $$$0.$$$ Do you think it will actually work?

Hint
Test Case (Don't see before understanding the hint)
»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

It's my first time for post so sorry for that

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think you can just remove your code. The submission link is enough. Also if your doubt is resolved just write [SOLVED] or [RESOLVED] at the start of topic so people know your doubt has been cleared.

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

This is my submission: 167158337.