public void QueryNaiveTest([Range(1, 30)] int n) { for (var ph = 0; ph < 10; ph++) { var lst = new LazySegmentTree <Monoid, Map>(n, new Oracle()); var timeManager = new TimeManager(n); for (var i = 0; i < n; i++) { lst.Set(i, new Monoid(i, i + 1, -1)); } var now = 0; for (var q = 0; q < 3000; q++) { var ty = Utilities.RandomInteger(0, 3); var(l, r) = Utilities.RandomPair(0, n); switch (ty) { case 0: { var result = lst.Query(l, r); Assert.That(result.L, Is.EqualTo(l)); Assert.That(result.R, Is.EqualTo(r)); Assert.That(result.Time, Is.EqualTo(timeManager.Query(l, r))); break; } case 1: { var result = lst.Get(l); Assert.That(result.L, Is.EqualTo(l)); Assert.That(result.L + 1, Is.EqualTo(l + 1)); Assert.That(result.Time, Is.EqualTo(timeManager.Query(l, l + 1))); break; } case 2: now++; lst.Apply(l, r, new Map(now)); timeManager.Action(l, r, now); break; case 3: now++; lst.Apply(l, new Map(now)); timeManager.Action(l, l + 1, now); break; default: throw new InvalidOperationException(); } } } }
public void MaxLeftTest([Range(1, 30)] int n) { for (var ph = 0; ph < 10; ph++) { var lst = new LazySegmentTree <Monoid, Map>(n, new Oracle()); var timeManager = new TimeManager(n); for (var i = 0; i < n; i++) { lst.Set(i, new Monoid(i, i + 1, -1)); } var now = 0; for (var q = 0; q < 1000; q++) { var ty = Utilities.RandomInteger(0, 2); var(l, r) = Utilities.RandomPair(0, n); if (ty == 0) { bool F(Monoid s) { if (s.L == -1) { return(true); } return(l <= s.L); } Assert.That(lst.MinLeft(r, F), Is.EqualTo(l)); } else { now++; lst.Apply(l, r, new Map(now)); timeManager.Action(l, r, now); } } } }