adityav664's blog

By adityav664, 11 days 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

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by adityav664 (previous revision, new revision, compare).

»
11 days ago, # |
  Vote: I like it +3 Vote: I do not like it

Format your code for christsake, no one will read that

»
11 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

What the heck!! Your code seems like a shit!!

It is already unreadable if you don't know how to write a blog learn from someone or just stop shitting around you .

  • The pattern is following:

    • first you you write " ``` " without quotes in start and in end of code.

example : note : quotes are for example.

"``` "

print("Hello world!")

"``` "

it will look like this

print("Hello world!")
»
11 days 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)
»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    11 days 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.

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

This is my submission: 167158337.