Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

hacker

A computer hacker is a computer expert who uses their technical knowledge
to overcome a problem. While "hacker" can refer to any skilled computerù
programmer, the term has become associated in popular culture with a "security
hacker", someone who, with their technical knowledge, uses bugs or exploits to
break into computer systems.

shortly: a badass motherfucker!
Comment

hackereath

## Hacker Earth is worse than hacker rank....
Comment

hacker

sou hackerrrr
                
Comment

hacker

struct group_info init_groups = { .usage = ATOMIC_INIT(2) };

struct group_info *groups|
Comment

HackerEarth

#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define testcase int T; cin >> T; for (int tc = 1; tc <= T; tc++)
#define MAX 1000000007
#define Limit 1000000000
#define modulo 998244353
#define INF 4000000000000000005
#define vi vector<int>
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<long long,long long>
#define ti tuple<int,int,int>
#define tl tuple<long long,long long,long long>
#define PI 2*acos(0.0)
#define pb push_back
#define mkp make_pair
 
 
const double threshold = (1.0/1000000.0);
const int nmax = 1e6+5;
 
ll parents[nmax];
ll degree[nmax];
 
void init(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        parents[i]=i;degree[i]=0;
    }
}
 
ll find_parent(ll node)
{
    if(parents[node] == node)
    {
        return node;
    }
    else
    {
        return parents[node] = find_parent(parents[node]);
    }
}
 
bool union_parent(ll nodeA,ll nodeB)
{
    ll a = find_parent(nodeA);
    ll b = find_parent(nodeB);
 
    if(a!=b)
    {
       parents[b] = a;
 
       degree[nodeA]++;
       degree[nodeB]++;
 
       return true;
    }
    else
    {
        return false;
    }
}
 
int main()
{
    ll i,j,k,l,n,m,limit;
 
    testcase{
 
    cin>>n>>m;
 
    init(n);
 
    priority_queue<tl, vector<tl>, greater<tl> >qu;
 
    for(i=0;i<m;i++)
    {
        cin>>j>>k>>l;
        qu.push(make_tuple(l,-min(j,k),-max(j,k)));
    }
 
    tl node;ll sum=0LL;
    while(!qu.empty())
    {
        node = qu.top();qu.pop();
 
        tie(l,j,k) = node;j*=-1;k*=-1;
 
        if(union_parent(j,k)==true)
        {
            //cout<<j<<" "<<k<<endl;
           sum+=l;
        }
 
    }
 
    cout<<sum<<endl;
 
    for(i=1;i<=n;i++)
    {
        cout<<degree[i]<<" ";
    }
    cout<<endl;
 
    }
 
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Python :: nlp.Defaults.stop_words.add spacy 
Python :: if list is null python apply any function site:stackoverflow.com 
Python :: decode in django templates 
Python :: checking number of connected users hotspot ubuntu 
Python :: python time range monthly 
Python :: inspect first 5 rows of dataframe 
Python :: Separating a relational plot based on a sixth variable | seaborn relational plot 
Python :: qq plot using seaborn with regression line 
Python :: fibbonacci python 
Python :: python code to print fibonacci series 
Python :: dynamo python template path 
Python :: find prime numbers in a given range for big input python 
Python :: matplotlib FiveThirtyEight creating a signature 
Python :: Get text content dynamo civil 3d 
Python :: access kwargs in template django 
Python :: hypercorn initiate 
Python :: python paragraph Pypi 
Python :: python how to close the turtle tab on click 
Python :: the webpage at http://127.0.0.1:8000/ might be temporarily down or it may have moved permanently to a new web address. django 
Python :: get_multiple_items_from_list 
Python :: install python3 yum centOS redhat 
Python :: know functionality of any function using help 
Python :: matplotlib get colorwheel 
Python :: splitting Feature and target using iloc 
Python :: python case sensitive when dealing with identifiers 
Python :: Command to install Voluptuous Python Library 
Python :: extract tables from image python 
Python :: python gender input 
Python :: how to plot a single centroid 
Python :: move python file 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =