Skip to content

Gaussian Elimination lecture

Errichto edited this page Nov 14, 2023 · 23 revisions

Gaussian Elimination

  • pronounce with 's', not 'sh'
  • solve a system of two equations
  • solve a system of three equations
  • talk about matrix representation
  • show a general algorithm
  • simulate on the same system of three equations
  • precision issues, pivot
  • usually computed modulo P, same but with modular inverse
  • binary version
  • example explained here https://en.wikipedia.org/wiki/Gaussian_elimination
  • practical programming use https://cp-algorithms.com/linear_algebra/linear-system-gauss.html
  • think: does the answer always exist modulo P?
    • x * 1000000007 = 5 has a solution for real values, doesn't for P=1e9+7

Existing resources

Introduction

  • Real values, N, a[i] <= 5, exactly one solution, error 1e-4, print the one solution
  • N <= 100 modulo P, say 0 or 1 or many solutions

Binary

  • number of XORS of subsets, N <= 5e5, a[i] <= 1e18
  • XOR maximization https://www.spoj.com/problems/XMAX/
  • Zero XOR Subset https://codeforces.com/contest/1101/problem/G
  • You are given a sequence of integers (N <= 10^5, a[i] <= 10^9) and there are two players. First Alice removes some numbers and then Bob removes some of the remaining numbers but can't remove everything. Then they play a NIM game, Alice starts. How many numbers at least should Alice remove in order to ensure the victory in NIM game later? This is a very simplified problem Magic Matches Game https://community.topcoder.com/stat?c=problem_statement&pm=11676 .
  • Same problem but every number has a price of removing b[i]. This time Alice pays for removing numbers and needs to minimize the total cost.

Binary Extra

complexityO(Q*log^3) with a segment tree

Random Walk general

Random Walk By One

ev[1] = x

ev[1] = ... * ev[2] + ... * ev[1] -> ev[2] = a * x + b

0.6 forward, else backward by 1

ev[1] = x ev[2] = 5 * x + 10 ...

ev[5] = p1 * ev[6] + p2 * ev[4] + p3 * ev[3] + const ev[6] = (p2 * ev[4] + p3 * ev[3] - ev[5]) / p1 + const why SUM can't be 0?

Maybe