Submission #68181235


Source Code Expand

using CpLibrary.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Threading;
namespace CpLibrary.Contest
{
	public class SolverB : SolverBase
	{
		static void Main() => OnlineJudge.Run(new SolverB());

		public override void Solve()
		{
			var (n, m) = sr.ReadValue<int, int>();
			var a = sr.ReadLongArray(n);
			var b = sr.ReadLongArray(m);
			var ans = new MultiSet<long>(a);
			foreach (var e in b)
			{
				ans.Remove(e);
			}
			sw.WriteLine(ans.Join(" "));
		}

		public override void Init()
		{
			/*
			 * Write your init code here!
			 */
		}
	}
}
#region Expanded by https://github.com/kzrnm/SourceExpander
namespace CpLibrary.Collections { public class MultiSet<T> : Set<T> where T : IComparable<T> { public MultiSet() : base(isMultiSet: true) { }  public MultiSet(IComparer<T> comparer) : base(comparer, true) { }  public MultiSet(Comparison<T> comparison) : base(comparison, true) { }  public MultiSet(IEnumerable<T> list) : base(list, true) { }  public MultiSet(IEnumerable<T> list, IComparer<T> comparer) : base(comparer, true) { }  public MultiSet(IEnumerable<T> list, Comparison<T> comparison) : base(list, comparison, true) { } } }
namespace CpLibrary.Collections { public class Set<T> : IEnumerable<T> where T : IComparable<T> { Node root; readonly IComparer<T> comparer; readonly Node nil; public bool IsMultiSet { get; }  public Set(bool isMultiSet = false) : this(Comparer<T>.Default, isMultiSet) { }  public Set(IComparer<T> comparer, bool isMultiSet = false) { nil = new Node(default); root = nil; this.comparer = comparer; this.IsMultiSet = isMultiSet; }  public Set(IEnumerable<T> list, bool isMultiSet = false) : this(list, Comparer<T>.Default, isMultiSet) { }  public Set(IEnumerable<T> list, IComparer<T> comparer, bool isMultiSet = false) : this(comparer, isMultiSet) { foreach (var item in list) { Add(item); } }  public Set(Comparison<T> comparison, bool isMultiSet = false) : this(Comparer<T>.Create(comparison), isMultiSet) { }  public Set(IEnumerable<T> list, Comparison<T> comparison, bool isMultiSet = false) : this(list, Comparer<T>.Create(comparison), isMultiSet) { }  public T this[int index] { get { if (index < 0 || root.Count < index) throw new ArgumentOutOfRangeException(); return Find(root, index); } }  public bool Add(T x) => Insert(ref root, x); public bool Remove(T x) => Erase(ref root, x); public void RemoveAt(int index) { if (index < 0 || Count < index) throw new ArgumentOutOfRangeException(); EraseAt(ref root, index); }  public bool Contains(T x) => this.Count == 0 ? false : EqualRange(x) > 0; public int LowerBound(T x) => BinarySearch(root, x, false); public int UpperBound(T x) => BinarySearch(root, x, true); public int EqualRange(T x) => UpperBound(x) - LowerBound(x); public void Clear() => root = nil; public T Min() => root.Min.Value; public T Max() => root.Max.Value; public T[] Items { get { var a = new T[root.Count]; var k = 0; Walk(root, a, ref k); return a; } }  public int Count => root.Count; public int Height => root.Height;  public IEnumerator<T> GetEnumerator() { return Items.AsEnumerable().GetEnumerator(); }  System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); bool Insert(ref Node p, T x) { if (p.Count == 0) { p = new Node(x); p.Left = p.Right = nil; p.Update(); return true; }  bool ret; var t = comparer.Compare(p.Value, x); if (t > 0) { ret = Insert(ref p.Left, x); } else if (t < 0) { ret = Insert(ref p.Right, x); } else { if (IsMultiSet == true) ret = Insert(ref p.Left, x); else return false; }  Balance(ref p); return ret; }  bool Erase(ref Node p, T x) { if (p.Count == 0) return false; var t = comparer.Compare(p.Value, x); bool ret; if (t < 0) ret = Erase(ref p.Right, x); else if (t > 0) ret = Erase(ref p.Left, x); else { ret = true; if (p.Right.Count == 0) { p = p.Left; return true; }  if (p.Left.Count == 0) { p = p.Right; return true; }  p.Value = p.Left.Max.Value; Erase(ref p.Left, p.Left.Max.Value); }  Balance(ref p); return ret; }  void EraseAt(ref Node p, int index) { var count = p.Left.Count; if (index < count) EraseAt(ref p.Left, index); else if (index > count) EraseAt(ref p.Right, index - count - 1); else { if (p.Left.Count == 0) { p = p.Right; return; }  if (p.Right.Count == 0) { p = p.Left; return; }  p.Value = p.Left.Max.Value; EraseAt(ref p.Left, index - 1); }  Balance(ref p); }  void Walk(Node t, T[] a, ref int k) { if (t.Count == 0) return; Walk(t.Left, a, ref k); a[k++] = t.Value; Walk(t.Right, a, ref k); }  void Balance(ref Node p) { var balance = p.Left.Height - p.Right.Height; if (balance < -1) { if (p.Right.Left.Height - p.Right.Right.Height > 0) RotateR(ref p.Right); RotateL(ref p); } else if (balance > 1) { if (p.Left.Left.Height - p.Left.Right.Height < 0) RotateL(ref p.Left); RotateR(ref p); } else p.Update(); }  T Find(Node p, int index) { if (index < p.Left.Count) return Find(p.Left, index); if (index > p.Left.Count) return Find(p.Right, index - p.Left.Count - 1); return p.Value; }  void RotateL(ref Node p) { var r = p.Right; p.Right = r.Left; r.Left = p; p.Update(); r.Update(); p = r; }  void RotateR(ref Node p) { var l = p.Left; p.Left = l.Right; l.Right = p; p.Update(); l.Update(); p = l; }  int BinarySearch(Node p, T x, bool isUpperBound) { if (p.Count == 0) throw new NullReferenceException(); var node = p; var ret = 0; while (p.Count != 0) { var cmp = p.Value.CompareTo(x); if (cmp > 0 || (!isUpperBound && cmp == 0)) { p = p.Left; } else { ret += p.Left.Count + 1; p = p.Right; } }  return ret; }  public override string ToString() { return string.Join(", ", Items); }  class Node { public Node Left, Right; public T Value { get; set; } public int Count { get; private set; } public int Height { get; private set; }  public Node Min { get { if (Left.Count == 0) return this; else return Left.Min; } }  public Node Max { get { if (Right.Count == 0) return this; else return Right.Max; } }  public Node(T value) => Value = value; public void Update() { Count = Left.Count + Right.Count + 1; Height = System.Math.Max(Left.Height, Right.Height) + 1; }  public override string ToString() => $"Count = {Count}, Value = {Value}"; } } }
namespace CpLibrary { public abstract class SolverBase { public bool StartsOnThread { get; set; } = false; public int Testcases { get; set; } = 1;  public Scanner sr; public StreamWriter sw; public abstract void Init(); public abstract void Solve(); public void Run(StreamReader reader, StreamWriter writer) { this.sw = writer; sr = new Scanner(reader); Console.SetOut(writer); if (StartsOnThread) { var thread = new Thread(new ThreadStart(RunInternal), 1 << 27); thread.Start(); thread.Join(); } else { RunInternal(); } }  void RunInternal() { Init(); var testcases = Testcases; while (testcases-- > 0) { Solve(); } } }  public static partial class OnlineJudge { public static void Run(SolverBase solver) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var sr = new StreamReader(Console.OpenStandardInput()); solver.Run(sr, sw); Console.Out.Flush(); } } }
namespace CpLibrary { public static class Extention { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); public static string Join<T>(this IEnumerable<T> x, char separator) => string.Join(separator, x); public static int UpperBound<T>(this IList<T> list, T value) => list.BinarySearch(value, true, 0, list.Count, Comparer<T>.Default); public static int LowerBound<T>(this IList<T> list, T value) => list.BinarySearch(value, false, 0, list.Count, Comparer<T>.Default); public static int BinarySearch<T>(this IList<T> list, T value, bool isUpperBound, int index, int length, Comparer<T> comparer) { var ng = index - 1; var ok = index + length; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2; var res = comparer.Compare(list[mid], value); if (res < 0 || (isUpperBound && res == 0)) ng = mid; else ok = mid; }  return ok; }  public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; }  public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } }
namespace CpLibrary { public class Scanner { public StreamReader sr { get; private set; }  string[] str; int index; char[] separators; public Scanner(StreamReader sr, char[] separators) { this.sr = sr; this.separators = separators; str = new string[0]; index = 0; }  public Scanner(StreamReader sr) : this(sr, new char[] { ' ' }) { }  public Scanner() : this(new StreamReader(Console.OpenStandardInput()), new char[] { ' ' }) { }  public string Read() { if (index < str.Length) return str[index++]; string s; do s = sr.ReadLine(); while (s == ""); str = s.Split(separators, StringSplitOptions.RemoveEmptyEntries); index = 0; return str[index++]; }  public string ReadString() => Read(); public string[] ReadStringArray(int n) { var arr = new string[n]; for (int i = 0; i < n; i++) { arr[i] = ReadString(); }  return arr; }  public int ReadInt() => int.Parse(ReadString()); public int[] ReadIntArray(int n) => ReadValueArray<int>(n); public long ReadLong() => long.Parse(ReadString()); public long[] ReadLongArray(int n) => ReadValueArray<long>(n); public double ReadDouble() => double.Parse(ReadString()); public double[] ReadDoubleArray(int n) => ReadValueArray<double>(n); public BigInteger ReadBigInteger() => BigInteger.Parse(ReadString()); public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() => (ReadValue<T1>(), ReadValue<T2>()); public (T1, T2, T3) ReadValue<T1, T2, T3>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>()); public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>()); public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>()); public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>()); public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() => (ReadValue<T1>(), ReadValue<T2>(), ReadValue<T3>(), ReadValue<T4>(), ReadValue<T5>(), ReadValue<T6>(), ReadValue<T7>()); public T1[] ReadValueArray<T1>(int n) { var arr = new T1[n]; for (int i = 0; i < n; i++) { arr[i] = ReadValue<T1>(); }  return arr; }  public (T1[], T2[]) ReadValueArray<T1, T2>(int n) { var(v1, v2) = (new T1[n], new T2[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i]) = ReadValue<T1, T2>(); }  return (v1, v2); }  public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int n) { var(v1, v2, v3) = (new T1[n], new T2[n], new T3[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i]) = ReadValue<T1, T2, T3>(); }  return (v1, v2, v3); }  public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int n) { var(v1, v2, v3, v4) = (new T1[n], new T2[n], new T3[n], new T4[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i]) = ReadValue<T1, T2, T3, T4>(); }  return (v1, v2, v3, v4); }  public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int n) { var(v1, v2, v3, v4, v5) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i]) = ReadValue<T1, T2, T3, T4, T5>(); }  return (v1, v2, v3, v4, v5); }  public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int n) { var(v1, v2, v3, v4, v5, v6) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i]) = ReadValue<T1, T2, T3, T4, T5, T6>(); }  return (v1, v2, v3, v4, v5, v6); }  public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var(v1, v2, v3, v4, v5, v6, v7) = (new T1[n], new T2[n], new T3[n], new T4[n], new T5[n], new T6[n], new T7[n]); for (int i = 0; i < n; i++) { (v1[i], v2[i], v3[i], v4[i], v5[i], v6[i], v7[i]) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); }  return (v1, v2, v3, v4, v5, v6, v7); }  public (T1, T2)[] ReadTupleArray<T1, T2>(int n) { var ret = new (T1, T2)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2>(); }  return ret; }  public (T1, T2, T3)[] ReadTupleArray<T1, T2, T3>(int n) { var ret = new (T1, T2, T3)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3>(); }  return ret; }  public (T1, T2, T3, T4)[] ReadTupleArray<T1, T2, T3, T4>(int n) { var ret = new (T1, T2, T3, T4)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4>(); }  return ret; }  public (T1, T2, T3, T4, T5)[] ReadTupleArray<T1, T2, T3, T4, T5>(int n) { var ret = new (T1, T2, T3, T4, T5)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5>(); }  return ret; }  public (T1, T2, T3, T4, T5, T6)[] ReadTupleArray<T1, T2, T3, T4, T5, T6>(int n) { var ret = new (T1, T2, T3, T4, T5, T6)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6>(); }  return ret; }  public (T1, T2, T3, T4, T5, T6, T7)[] ReadTupleArray<T1, T2, T3, T4, T5, T6, T7>(int n) { var ret = new (T1, T2, T3, T4, T5, T6, T7)[n]; for (int i = 0; i < n; i++) { ret[i] = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); }  return ret; } } }
#endregion Expanded by https://github.com/kzrnm/SourceExpander

Submission Info

Submission Time
Task B - Search and Delete
User fairy_lettuce
Language C# 11.0 (.NET 7.0.7)
Score 200
Code Size 13523 Byte
Status AC
Exec Time 58 ms
Memory 27208 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 28
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 49 ms 26628 KiB
example_01.txt AC 53 ms 26388 KiB
hand_00.txt AC 44 ms 26528 KiB
hand_01.txt AC 50 ms 26460 KiB
hand_02.txt AC 46 ms 26724 KiB
hand_03.txt AC 45 ms 26876 KiB
hand_04.txt AC 42 ms 26788 KiB
hand_05.txt AC 44 ms 26648 KiB
random_00.txt AC 44 ms 26956 KiB
random_01.txt AC 50 ms 26828 KiB
random_02.txt AC 54 ms 26956 KiB
random_03.txt AC 58 ms 26940 KiB
random_04.txt AC 46 ms 27208 KiB
random_05.txt AC 52 ms 26592 KiB
random_06.txt AC 46 ms 26668 KiB
random_07.txt AC 51 ms 26836 KiB
random_08.txt AC 51 ms 26860 KiB
random_09.txt AC 44 ms 27012 KiB
random_10.txt AC 58 ms 26756 KiB
random_11.txt AC 54 ms 26900 KiB
random_12.txt AC 50 ms 26948 KiB
random_13.txt AC 54 ms 27044 KiB
random_14.txt AC 55 ms 26944 KiB
random_15.txt AC 55 ms 26624 KiB
random_16.txt AC 50 ms 26768 KiB
random_17.txt AC 43 ms 26860 KiB
random_18.txt AC 48 ms 26956 KiB
random_19.txt AC 43 ms 26936 KiB