Блог пользователя adityav664

Автор adityav664, 2 года назад, По-английски

I have issue in question named as C. Rumor -893C, link :- https://codeforces.net/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.net/contest/893/submission/167180749. thanks in advance.

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Format your code for christsake, no one will read that

»
2 года назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

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)
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

This is my submission: 167158337.