<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * Dany jest graf w postaci
 * w pierwszym wierszu zapisane sÄ dwie liczby caĹkowite n i m
 * odpowiednio liczba wierzchoĹkĂłw (2 &lt;= n &lt;= 1000)
 * oraz liczba krawÄdzi (2 &lt;= m &lt;= 100000)
 * W kolejnych m wierszach zapisane sÄ krawÄdzie.
 * KaĹźdy z m wierszy zawiera dwie liczby caĹkowite a_i i b_i,
 * oznaczajÄce, Ĺźe wierzchoĹki a_i i b_i sÄ poĹÄczone krawÄdziÄ.
 *
 * NaleĹźy wyznaczyÄ podziaĹ wierzchoĹkĂłw grafu na rozĹÄczone zbiory
 * V_1, V_2, \ldots, V_k
 * tak by:
 * - zmaksymalizowaÄ liczbÄ podzbiorĂłw
 * - jeĹli a \in V_i, b\in V_j oraz i&lt;&gt;j, to wierzchoĹki a i b muszÄ
 *   byÄ poĹÄczone krawÄdziÄ
 *
 * Oczekiwany format wyjĹcia:
 * jedna liczba caĹkowita - maksymalna liczba podzbiorĂłw
 */


import org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

import java.math.BigInteger;
import java.io.*;
import java.util.Scanner;


public class zadanieGrafoweTest {

    private ByteArrayOutputStream outContent;;

    private void setUpStreams(String inp) {
        outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        System.setIn(new ByteArrayInputStream(inp.getBytes()));
    }

    private void cleanUpStreams() {
        System.setOut(null);
        System.setIn(null);
    }

    private String runProgram(String inp) {
        try {
            setUpStreams(inp);
            Main.main(new String[0]);
            return outContent.toString();
        } finally {
            cleanUpStreams();
        }
    }

    @Test
    public void testGrafPelny() {
      testuj("3 3\n1 2\n3 1\n3 2\n",3);
    }

    @Test
    public void testKwadrat() {
      testuj("4 4\n1 2\n3 4\n2 3\n4 1\n",2);
    }

    @Test
    public void testKwadratZPowtorzonaKrawedzia() {
      testuj("4 5\n1 2\n2 1\n3 4\n2 3\n4 1\n",2); // krawÄdz 1-2 jest powtĂłrzona!
    }


    @Test
    public void testKoperta() {
      // 1---------6
      // |\       /|
      // | 3-----4 |
      // |/       \|
      // 2---------5
      testuj("6 9\n1 2\n2 3\n3 1\n3 4\n\n4 5\n5 6\n6 4\n1 6\n2 5\n",1);
    }

    @Test
    public void testGrafPusty3() {
      testuj("3 0\n",1);
    }

    @Test
    public void testGrafPusty100() {
      testuj("100 0\n",1);
    }

    @Test(timeout=2000)
    public void testGrafPusty1000() {
      testuj("1000 0\n",1);
    }

    @Test(timeout=2000)
    public void testGrafPusty10000() {
      testuj("10000 0\n",1);
    }

    @Test(timeout=2000)
    public void testGrafJednaKrawedzN10000() {
      testuj("10000 1\n1 2\n",1);
    }

    private void testuj(String inp, int odp) {
        String should_be=""+odp+"\n";
        assertEquals(should_be, runProgram(inp));
    }


}
</pre></body></html>