Exemplo n.º 1
0
    private static void Main()
    {
        int remainingTestCases = FastIO.ReadNonNegativeInt();

        while (remainingTestCases-- > 0)
        {
            int matrixSize = FastIO.ReadNonNegativeInt();
            var solver     = new MATSUM(matrixSize);

            char command;
            while ((command = FastIO.ReadCommand()) != 'E')
            {
                if (command == 'S')
                {
                    solver.Set(
                        rowIndex: FastIO.ReadNonNegativeInt(),
                        columnIndex: FastIO.ReadNonNegativeInt(),
                        value: FastIO.ReadInt());
                }
                else
                {
                    FastIO.WriteInt(solver.Query(
                                        nearRowIndex: FastIO.ReadNonNegativeInt(),
                                        nearColumnIndex: FastIO.ReadNonNegativeInt(),
                                        farRowIndex: FastIO.ReadNonNegativeInt(),
                                        farColumnIndex: FastIO.ReadNonNegativeInt()));
                    FastIO.WriteLine();
                }
            }
            FastIO.WriteLine();
        }

        FastIO.Flush();
    }
Exemplo n.º 2
0
    private static void Main()
    {
        int arrayLength;

        while ((arrayLength = FastIO.ReadNonNegativeInt()) != 0)
        {
            int   queryCount  = FastIO.ReadNonNegativeInt();
            int[] sourceArray = new int[arrayLength];
            for (int i = 0; i < arrayLength; ++i)
            {
                sourceArray[i] = FastIO.ReadInt();
            }

            var solver = new FREQUENT(sourceArray);

            for (int q = 0; q < queryCount; ++q)
            {
                FastIO.WriteInt(solver.Query(
                                    queryStartIndex: FastIO.ReadNonNegativeInt() - 1,
                                    queryEndIndex: FastIO.ReadNonNegativeInt() - 1));
                FastIO.WriteLine();
            }
        }

        FastIO.Flush();
    }
Exemplo n.º 3
0
    private static void Main()
    {
        int n = FastIO.ReadNonNegativeInt();

        for (int i = 0; i < n; ++i)
        {
            FastIO.WriteInt(FastIO.ReadInt() * FastIO.ReadInt());
            FastIO.WriteLine();
        }

        FastIO.Flush();
    }
Exemplo n.º 4
0
    private static void Main()
    {
        int remainingTestCases = FastIO.ReadNonNegativeInt();

        while (remainingTestCases-- > 0)
        {
            FastIO.WriteInt(
                TEMPLATE3.Solve(FastIO.ReadInt(), FastIO.ReadInt()));
            FastIO.WriteLine();
        }

        FastIO.Flush();
    }
Exemplo n.º 5
0
    private static void Main()
    {
        int sourceArrayLength = FastIO.ReadNonNegativeInt();
        int queryCount        = FastIO.ReadNonNegativeInt();

        int[] sourceArray = new int[sourceArrayLength];
        for (int i = 0; i < sourceArrayLength; ++i)
        {
            sourceArray[i] = FastIO.ReadInt();
        }

        var solver = new MKTHNUM(sourceArray);

        for (int q = 0; q < queryCount; ++q)
        {
            FastIO.WriteInt(solver.Query(
                                queryStartIndex: FastIO.ReadNonNegativeInt() - 1,
                                queryEndIndex: FastIO.ReadNonNegativeInt() - 1,
                                k: FastIO.ReadNonNegativeInt()));
            FastIO.WriteLine();
        }

        FastIO.Flush();
    }