Friday, February 15, 2013

[UVa] 10926 - How many dependencies

#include <cstdio>
#include <iostream>

using namespace std;

#define init(n) { for (int i=0 ; i<=n ; i++) { visit[i] = false; for (int j=0 ; j<=n ; j++) adj[i][j] = adj[j][i] = false; } }

int n, dep[200], root[200], adj[200][200];
bool visit[200];

int dfs_visit(int s, int src) {

    root[s] = src;
    dep[s] = 0;
    for (int i=1 ; i<=n ; i++) {
        if (!visit[i] && adj[s][i]) {
            visit[i] = true;
            dep[s] += (dfs_visit(i,src)+1);
        }
    }
    return dep[s];
}

void dfs() {

    for (int i=1 ; i<=n ; i++) {
        for (int j=0 ; j<=n ; j++) visit[j] = false;
        dfs_visit(i,i);
    }

}

int main( void ) {

    int t, x, maxdepi, maxdep;

    while (scanf("%d",&n)==1 && n) {

        init(n);

        for (int i=1 ; i<=n ; i++) {
            scanf("%d",&t);
            for (int j=0 ; j<t ; j++) {
                scanf("%d",&x);
                adj[i][x] = true;
            }
        }


        dfs();

        maxdep = -1000;

        for (int i=1 ; i<=n ; i++) {


            if (dep[i]>maxdep) {
                maxdep = dep[i];
                maxdepi = i;

            }
        }

        printf("%d\n",maxdepi);

    }


    return 0;
}


Friday, February 01, 2013

XEN Hypervisor

This is something that I want to do in future with my system. Currently can't do it cuz I don't have the Hardware :S But I will :) [ http://forums.linuxmint.com/viewtopic.php?f=42&t=112013 ] [ http://blog.xen.org/ ]

How to Uninstall Linux / Remove GRUB / Go back to hell

Many users, mostly pretentious Linux enthusiasts come to me and ask "How to uninstall Linux". Apart from trying my best to hide my disgust (personal reasons, no offense), most of the time I answer like "It's hard to make you understand the process". Today when I was browsing the "How to" section of my favorite distro, I stumbled upon a collection of methods to do this. Here's the link:
[ http://forums.linuxmint.com/viewtopic.php?f=42&t=98051 ]
Directly quoting them in case the link becomes inactive when the info is needed. Method 1: Let me begin by saying I think Mint 12 is a terrific OS, which I am using on several computers. But I have computers on which I use Music Bee in Windows 7 for my music files and want direct boot to Windows without any disk space devoted to Mint. I spent several days looking at complicated instructions for removing Grub and finally accidentally discovered a simple solution, which is as follows: In Windows, download Partition Wizard at http://download.cnet.com/MiniTool-Partition-Wizard-Home-Edition/3000-2094_4-10962200.html. Install. Partitioning will be blocked by Grub. But on your left hit Rebuild MBR. This will take only a few seconds. Reboot, and Windows 7 will boot. Then you can go into Partition Wizard and eliminate the Ubuntu partitions and expand your Windows data partition to take up the freed up space.
Method 2: 1. Boot-Repair iso burnt into a CD will boot and, if you opt for fix mbr, then only windows will boot, provied Windows is on the first partition, of course. Partitions are not deleted.

Download site:
https://help.ubuntu.com/community/Boot-Repair

2. Another way, from Windows itself, run the free windows utility called mbrfix.

I used both, and both work great.
Method 3: Much easier way: Remove Grub bootloader using LILO.

1. Open terminal and run commands

sudo apt-get update
sudo apt-get install lilo
sudo lilo -M /dev/sda mbr # assuming that grub is installed to disk sda

A video about removing: http://www.youtube.com/watch?v=oB8NVzkgdEA&feature=plcp
Note: This method might need a Live Boot

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...