BZOJ1006 [HNOI2008] wonderful country

Tags: chord diagram

For definitions of the mcs algorithm chord chart, please self (template)

The meaning of problems for the sake of a few strings to Color \ (\ chi (G) \ )

practice:

Optimal staining structure: the perfect elimination of the minimum color sequence from the back in turn to each point dyeing, contracted for each point can be dyed

prove:

The method provided by the above \ (COL \) colors, the number of original group is \ (\ omega (G) \ )

Lemma: \ (\ Omega (G) \ Leq \ Chi (G) \)

Lemma: FIG stained largest sub-group derived, at least \ (\ omega (G) \ ) colors (as groups are adjacent to each point, each point required a different color)

Set \ (col \ geq \ chi ( G) \)

Each point on the different groups \ (\ rightarrow col = \ omega (G) \)

Lemma: \ (COL = \ Omega (G) \ Leq \ Chi (G) \) , \ (COL \ GEQ \ Chi (G) \)

$\therefore t = \omega(G) =\chi(G) $

\(ans = max\{|\{x\} + N(x)|\} = max\{lab_i\} + 1\)

Code: To open O2 optimization

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 1e4 + 1;

int n, m, u, v, lab[N], p[N];
bool c[N][N], vis[N];

inline void mcs()
{
    for (int i = n; i >= 1; --i)    
    {
        u = 0;
        for (int j = 1; j <= n; ++j)
            if (!vis[j] && (!u || lab[j] > lab[u]))
                u = j;
        vis[u] = 1;
        p[i] = u;
        for (int j = 1; j <= n; ++j)
            if (!vis[j] && c[u][j])
                ++lab[j];
    }       
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)    
    {
        cin >> u >> v;
        c[u][v] = c[v][u] = 1;
    }
    mcs();
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, lab[i] + 1);
    cout << ans << endl;
    return 0;
}

Guess you like

Origin www.cnblogs.com/pipa-peng/p/11886789.html