Tags » MST

Samsung Pay is officially Launched in India.

India is becoming Tech giant potential market as Microsoft launched Skype Lite and the likes now, another is rolling out today “Samsung Pay”.

Samsung Pay supports both NFC(Near Field Communication) and MST (Magnetic Secure Transmission). 151 more words

Gadgets

What is the difference? Galaxy Gear S3

Always feel jealous someone who has iWatch and iPhone…

Hi, this is Toni@Singapore:)

Finally, I bought Galaxy Gear s3 classic when I went to Johor Bahru(Malaysia) 291 more words

Android

Photo Scandal Hurts Effort To Change Marine Corps Culture

https://cpa.ds.npr.org/wunc2/audio/2017/03/njp031017-marine_photos_0.mp3

My colleague with the American Homefront Project, Jay Price,  reports on efforts to change the culture within the Marine Corps after revelations that hundreds of Marines shared lewd photos of women. 711 more words

Marines

Prim's Algorithm Animation for randomly distributed points

For a given set of randomly distributed points in 2-dimensional space, we utilize the Prim’s algorithm to find the minimum total distance from a randomly selected origin point (P_origin).The algorithm is written in C++, visualization is done via Python, video editing by Blender. 103 more words

Animation

UVa 10034 - Freckles

//aarifshuvo  ``CSEJU

#include <bits/stdc++.h>
#define ll long long
#define SZ(x) ((int)(x).size())
#define scl(x) scanf("%lld", &x)
#define scll(x,y) scanf("%lld %lld", &x, &y)
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
using namespace std;

typedef pair<double,double> pii;

struct edge
{
    int a,b;
    double c;

    edge(int _a, int _b, double _c)
    {
        a=_a, b=_b, c=_c;
    }

    bool operator < (const edge p) const
    {
        return c < p.c;
    }
};

double dist(double x1, double y1, double x2, double y2)
{
    double d = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    return d;
}

vector <pii> points;
vector<edge> edges;
map<int,int> par;

int findr(int r)
{
    if(par[r]==0) return r;

    int x = findr(par[r]);
    par[r] = x;
    return x;
}

int main()
{
    bool fl = false;
    int t,n;
    double x,y;
    scanf("%d", &t);
    getchar();
    while(t--)
    {
        if(fl) printf("\n"); fl = true;

        points.clear();
        edges.clear();
        par.clear();

        scanf("%d", &n);

        REP(i,n)
        {
             scanf("%lf%lf", &x, &y);
             points.push_back(make_pair(x,y));
        }

        REP(i,n)
        {
            FOR(j,i+1,n-1)
            {

                int ii = i+1, jj = j+1;
                double dd = dist(points[i].first, points[i].second,
                                points[j].first, points[j].second);

                edges.push_back(edge(ii,jj,dd));
            }
        }

        sort(ALL(edges));

        double mstsm = 0;

        REP(i,SZ(edges))
        {
            int u = findr(edges[i].a),
                v = findr(edges[i].b);

            if(u!=v) par[v] = u, mstsm += edges[i].c;
        }

        printf("%.2lf\n", mstsm);

    }
    return 0;
}
UVa

UVa 11631 - Dark Roads

//aarifshuvo   ``CSEJU

#include <bits/stdc++.h>
#define ll long long
#define SZ(x) ((int)(x).size())
#define scl(x) scanf("%lld", &x)
#define scll(x,y) scanf("%lld %lld", &x, &y)
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
using namespace std;

#define mx 200007

struct edge
{
    int a,b,c;

    edge(int _a, int _b, int _c)
    {
        a=_a, b=_b, c=_c;
    }

    bool operator < (const edge p) const
    {
        return (c < p.c);
    }
};

ll n,e;
vector <edge> graph;
ll par;

ll presm = 0;

int findr(int r)
{
    if(r==par[r]) return r;

    int x = findr(par[r]);
    par[r] = x;

    return  x;
}

ll mst()
{
    ll mstsm = 0;

    // init
    REP(i,mx) par[i] = i;

    //find
    REP(i,SZ(graph))
    {
        int x = findr(graph[i].a);
        int y = findr(graph[i].b);

        if(x!=y) par[y] = x , mstsm += graph[i].c;
    }
    return mstsm;
}

ll x,y,z;

int main()
{
    while(scll(n,e) and n+e)
    {
        presm = 0;

        REP(i,e)
        {
            scll(x,y); scl(z);
            graph.push_back(edge(x,y,z));
            presm += z;
        }

        sort(ALL(graph));

        ll res = presm - mst();
        printf("%lld\n", res);

        graph.clear();
    }
    return 0;
}
UVa