Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Matr
- {
- List<List<long>> d;
- private int n, m;
- public Matr(int n, int m)
- {
- this.n = n;
- this.m = m;
- d = new List<List<long>>(n);
- for (int i = 0; i < n; i++)
- {
- d.Add(new List<long>(m));
- for (int j = 0; j < m; j++)
- {
- d[i].Add(0);
- }
- }
- }
- public void Add(long l, long r, long x)
- {
- for (int i = Convert.ToInt32(l); i <= r; i++)
- {
- for (int j = 0; j < m; j++)
- {
- d[j][i] += x;
- }
- }
- }
- public void Change(int i, long x)
- {
- List<long> changeList = new List<long>(n);
- for (int j = 0; j < m; j++)
- changeList.Add(x);
- d[i] = changeList;
- }
- public long Get(int i, int j)
- {
- return d[i][j];
- }
- }
- class Program
- {
- public static void Main(string[] args)
- {
- string? input = Console.ReadLine();
- if (input == null) return;
- int n, m, countQ, q;
- n = Convert.ToInt32(input.Split(' ')[0]);
- m = Convert.ToInt32(input.Split(' ')[1]);
- countQ = Convert.ToInt32(input.Split(' ')[2]);
- Matr matr = new Matr(n, m);
- for (int it = 0; it < countQ; it++)
- {
- input = Console.ReadLine();
- if (input == null) return;
- q = Convert.ToInt32(input.Split(' ')[0]);
- switch (q)
- {
- case 1:
- long l = Convert.ToInt64(input.Split(' ')[1]);
- long r = Convert.ToInt64(input.Split(' ')[2]);
- long x = Convert.ToInt64(input.Split(' ')[3]);
- l--;
- r--;
- matr.Add(l, r, x);
- break;
- case 2:
- int i = Convert.ToInt32(input.Split(' ')[1]);
- long xx = Convert.ToInt64(input.Split(' ')[2]);
- i--;
- matr.Change(i, xx);
- break;
- case 3:
- int ii = Convert.ToInt32(input.Split(' ')[1]);
- int j = Convert.ToInt32(input.Split(' ')[2]);
- ii--;
- j--;
- Console.WriteLine(matr.Get(ii, j));
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement