提出 #549557


ソースコード 拡げる

	using System;
	using System.Collections.Generic;
	using System.IO;
	using System.Linq;
	class Problem : IDisposable
	{
		private Scanner sc;
		private Printer pr;
		public Problem()
		{
			sc = new Scanner();
			pr = new Printer();
			Initiate();
		}
		public void Dispose()
		{
			pr.Dispose();
			sc.Dispose();
		}
		private int N;
		private Tuple<int, int>[] A;
		private void Initiate()
		{
			sc.Read(out N);
			A = new Tuple<int, int>[N];
			for (int i = 0; i < N; i++)
			{
				var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
				A[i] = new Tuple<int, int>(input[0], input[1]);
			}
		}
		public void Solve()
		{
			int[] point = new int[1<<30];
			int[] result = new int[N];
			var warp = new int[1<<30];
			for (int i = 0; i < N; i++)
			{
				int step;
				int count = A[i].Item1;
				if (point[count] == 0)
				{
					point[count] = 1;
					step = 1;
				}
				else
					step = 0;
				count++;
				while (step < A[i].Item2)
				{
					if (point[count] == 0)
					{ point[count] = 1; count++; step++; }
					else
					{
						count+=warp[count]+1;
					}
				}
				warp[A[i].Item1] = count - 1 - A[i].Item1;
				result[i] = count - 1;
			}
			foreach (var x in result)
			{
				pr.WriteLine(x);
			}

		}
	}
	class Program
	{
		static void Main()
		{
			using (var problem = new Problem()) problem.Solve();
		}
	}
	class Pair<S, T>
	{
		public S First;
		public T Second;
		public Pair() { First = default(S); Second = default(T); }
		public Pair(S s, T t) { First = s; Second = t; }
		public override string ToString() { return "(" + First + ", " + Second + ")"; }
		public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
		public override bool Equals(object obj)
		{
			if (ReferenceEquals(this, obj)) return true;
			else if (obj == null) return false;
			var tmp = obj as Pair<S, T>;
			return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
		}
	}
	class Point : Pair<int, int>
	{
		public int X { get { return First; } set { First = value; } }
		public int Y { get { return Second; } set { Second = value; } }
		public Point() : base(0, 0) { }
		public Point(int x, int y) : base(x, y) { }
		public IEnumerable<Point> Neighbors4()
		{
			yield return new Point(X - 1, Y);
			yield return new Point(X, Y - 1);
			yield return new Point(X, Y + 1);
			yield return new Point(X + 1, Y);
		}
		public IEnumerable<Point> Neighbors8()
		{
			yield return new Point(X - 1, Y - 1);
			yield return new Point(X - 1, Y);
			yield return new Point(X - 1, Y + 1);
			yield return new Point(X, Y - 1);
			yield return new Point(X, Y + 1);
			yield return new Point(X + 1, Y - 1);
			yield return new Point(X + 1, Y);
			yield return new Point(X + 1, Y + 1);
		}
	}
	class Printer : IDisposable
	{
		private TextWriter file;
		public Printer() { file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; }
		public Printer(string path) { file = new StreamWriter(path, false) { AutoFlush = false }; }
		public void Write<T>(T value) { file.Write(value); }
		public void Write(string str, params object[] args) { file.Write(str, args); }
		public void WriteLine() { file.WriteLine(); }
		public void WriteLine<T>(T value) { file.WriteLine(value); }
		public void WriteLine(string str, params object[] args) { file.WriteLine(str, args); }
		public void Dispose() { file.Flush(); }
	}
	class Scanner : IDisposable
	{
		private TextReader file;
		public Scanner() { file = Console.In; }
		public Scanner(string path) { file = new StreamReader(path); }
		public void Dispose() { if (file != Console.In) file.Dispose(); }
		public T Get<T>() { return (T)Convert(file.ReadLine(), Type.GetTypeCode(typeof(T))); }
		public Tuple<S, T> Get<S, T>() { S s; T t; Read(out s, out t); return new Tuple<S, T>(s, t); }
		public Tuple<S, T, U> Get<S, T, U>() { S s; T t; U u; Read(out s, out t, out u); return new Tuple<S, T, U>(s, t, u); }
		public Tuple<S, T, U, V> Get<S, T, U, V>() { S s; T t; U u; V v; Read(out s, out t, out u, out v); return new Tuple<S, T, U, V>(s, t, u, v); }
		public Pair<S, T> Pair<S, T>() { S s; T t; Read(out s, out t); return new Pair<S, T>(s, t); }
		private object Convert(string str, TypeCode type)
		{
			if (type == TypeCode.Int32) return int.Parse(str);
			else if (type == TypeCode.UInt32) return uint.Parse(str);
			else if (type == TypeCode.Int64) return long.Parse(str);
			else if (type == TypeCode.UInt64) return ulong.Parse(str);
			else if (type == TypeCode.Double) return double.Parse(str);
			else if (type == TypeCode.Decimal) return decimal.Parse(str);
			else if (type == TypeCode.String) return str;
			else throw new Exception();
		}
		public T[] ReadMany<T>(int n) { var type = Type.GetTypeCode(typeof(T)); return file.ReadLine().Split().Select(str => (T)Convert(str, type)).ToArray(); }
		public T[] ReadManyLines<T>(int n, Func<T> selector) { return Enumerable.Range(0, n).Select(_ => selector()).ToArray(); }
		public T[] ReadManyLines<T>(int n) { return Enumerable.Range(0, n).Select(_ => Get<T>()).ToArray(); }
		public Tuple<S, T>[] ReadManyLines<S, T>(int n) { return Enumerable.Range(0, n).Select(_ => Get<S, T>()).ToArray(); }
		public Tuple<S, T, U>[] ReadManyLines<S, T, U>(int n) { return Enumerable.Range(0, n).Select(_ => Get<S, T, U>()).ToArray(); }
		public Tuple<S, T, U, V>[] ReadManyLines<S, T, U, V>(int n) { return Enumerable.Range(0, n).Select(_ => Get<S, T, U, V>()).ToArray(); }
		public void Read<S>(out S s)
		{
			var read = ReadMulti(Type.GetTypeCode(typeof(S))).ToArray();
			s = (S)read[0];
		}
		public void Read<S, T>(out S s, out T t)
		{
			var read = ReadMulti(Type.GetTypeCode(typeof(S)), Type.GetTypeCode(typeof(T))).ToArray();
			s = (S)read[0];
			t = (T)read[1];
		}
		public void Read<S, T, U>(out S s, out T t, out U u)
		{
			var read = ReadMulti(Type.GetTypeCode(typeof(S)), Type.GetTypeCode(typeof(T)), Type.GetTypeCode(typeof(U))).ToArray();
			s = (S)read[0];
			t = (T)read[1];
			u = (U)read[2];
		}
		public void Read<S, T, U, V>(out S s, out T t, out U u, out V v)
		{
			var read = ReadMulti(Type.GetTypeCode(typeof(S)), Type.GetTypeCode(typeof(T)), Type.GetTypeCode(typeof(U)), Type.GetTypeCode(typeof(V))).ToArray();
			s = (S)read[0];
			t = (T)read[1];
			u = (U)read[2];
			v = (V)read[3];
		}
		private IEnumerable<object> ReadMulti(params TypeCode[] types)
		{
			var inp = file.ReadLine().Split();
			for (var i = 0; i < types.Length; i++) yield return Convert(inp[i], types[i]);
		}
		public T[,] Board<T>(int X, int Y, Func<char, int, int, T> selector)
		{
			var array = new T[X, Y];
			for (var y = 0; y < Y; y++)
			{
				var str = Get<string>();
				for (var x = 0; x < X; x++) array[x, y] = selector(str[x], x, y);
			}
			return array;
		}
	}
	static class Func
	{
		public static int Division(string quotient, int divisor)
		{
			int reminder = 0;
			for (int i = 0; i < quotient.Length; i++)
			{
				reminder = (reminder * 10 + quotient[i] - '0') % divisor;
			}
			return reminder;
		}
		public static readonly int Inf = 1073741789;

		public static long FirstBinary(long min, long max, Predicate<long> pred)
		{
			var left = min;
			var right = max;
			while (left < right)
			{
				var mid = (left + right) >> 1;
				if (pred(mid)) right = mid;
				else left = mid + 1;
			}
			return left;
		}
	}
	class Graph
	{
		int V;
		List<Tuple<int, int, int>> edges;
		List<Tuple<int, int>>[] edgesFrom;
		List<Tuple<int, int>>[] edgesTo;
		public List<Tuple<int, int>> EdgeFrom(int from)
		{
			return edgesFrom[from];
		}
		public List<Tuple<int, int>> EdgeTo(int to)
		{
			return edgesTo[to];
		}

		public Graph(int V)
		{
			this.V = V;
			edges = new List<Tuple<int, int, int>>();
			edgesFrom = new List<Tuple<int, int>>[V];
			edgesTo = new List<Tuple<int, int>>[V];
			for (int i = 0; i < V; i++)
			{
				edgesFrom[i] = new List<Tuple<int, int>>();
				edgesTo[i] = new List<Tuple<int, int>>();
			}
		}

		public void Add(int from, int to, int cost)
		{
			var edge = new Tuple<int, int, int>(from, to, cost);
			this.edges.Add(edge);
			edgesFrom[from].Add(new Tuple<int, int>(to, cost));
			edgesTo[to].Add(new Tuple<int, int>(from, cost));
		}

		public int[] BellmanFord(int start)
		{
			var d = new int[V];
			for (int v = 0; v < V; v++)
			{
				d[v] = Func.Inf;
			}
			d[start] = 0;
			for (int i = 0; i < V; i++)
			{
				foreach (var e in edges)
				{
					if (d[e.Item1] != Func.Inf && d[e.Item2] > d[e.Item1] + e.Item3)
					{
						d[e.Item2] = d[e.Item1] + e.Item3;
						if (i == V - 1) return null;
					}
				}
			}
			return d;
		}

		public int[] Dijkstra(int start)
		{
			var que = new PriorityQueue<Tuple<int, int>>((x, y) => x.Item1.CompareTo(y.Item1));
			var d = new int[V];
			for (int v = 0; v < V; v++)
			{
				d[v] = Func.Inf;
			}
			d[start] = 0;
			que.Enqueue(new Tuple<int, int>(0, start));

			while (que.Count > 0)
			{
				var p = que.Dequeue();
				int v = p.Item2;
				if (d[v] < p.Item1) continue;
				foreach (var e in EdgeFrom(p.Item2))
				{
					if (d[e.Item1] > d[v] + e.Item2)
					{
						d[e.Item1] = d[v] + e.Item2;
						que.Enqueue(new Tuple<int, int>(d[e.Item1], e.Item1));
					}

				}
			}
			return d;
		}

		public int[,] WarshallFloyd()
		{
			var d = new int[V, V];
			for (int from = 0; from < V; from++)
			{
				for (int to = 0; to < V; to++)
				{
					d[from, to] = Func.Inf;
					if (from == to)
						d[from, to] = 0;
				}
			}
			foreach (var e in edges)
			{
				d[e.Item1, e.Item2] = Math.Min(d[e.Item1, e.Item2], e.Item3);
			}
			for (int k = 0; k < V; k++)
			{
				for (int i = 0; i < V; i++)
				{
					for (int j = 0; j < V; j++)
					{
						d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
					}
				}
			}
			return d;
		}
	}
	class UnionFindTree
	{
		int[] Par;
		int[] Rank;
		public UnionFindTree(int n)
		{
			Par = new int[n];
			Rank = new int[n];
			for (int i = 0; i < n; i++)
			{
				Par[i] = i;
				Rank[i] = 0;
			}
		}

		public int Find(int x) { return Par[x] == x ? x : Par[x] = Find(Par[x]); }

		public void Unite(int x, int y)
		{
			x = Find(x);
			y = Find(y);
			if (x == y) return;

			if (Rank[x] < Rank[y]) Par[x] = y;
			else { Par[y] = x; if (Rank[x] == Rank[y]) Rank[x]++; }
		}

		public bool IsSame(int x, int y) { return Find(x) == Find(y); }
		public void Print(Printer pr)
		{
			Console.Clear();
			for (int i = 0; i < Par.Length; i++)
			{
				pr.WriteLine("{0} -> {1}", i, Par[i]);
			}
		}

	}
	class PriorityQueue<T>
	{
		List<T> heap;
		int sz;
		Comparison<T> comp;
		public PriorityQueue() : this((x, y) => ((IComparable<T>)(x)).CompareTo(y)) { }
		public PriorityQueue(Comparison<T> comp)
		{
			heap = new List<T>();
			sz = 0;
			this.comp = comp;
		}
		public int Count { get { return sz; } }

		public void Enqueue(T x)
		{
			int i = sz++;
			if (sz > heap.Count) heap.Add(default(T));

			while (i > 0)
			{
				int p = (i - 1) / 2;
				if (comp(heap[p], x) <= 0) break;
				heap[i] = heap[p];
				i = p;
			}
			heap[i] = x;
		}
		public T Peek()
		{
			return heap[0];
		}
		public T Dequeue()
		{
			if (sz == 0) throw new InvalidOperationException("空のヒープからポップすることは出来ません。");
			T ret = heap[0];
			T x = heap[--sz];

			int i = 0;
			while (i * 2 + 1 < sz)
			{
				int a = i * 2 + 1, b = i * 2 + 2;
				if (b < sz && comp(heap[b], heap[a]) < 0) a = b;

				if (comp(heap[a], x) >= 0) break;

				heap[i] = heap[a];
				i = a;
			}

			heap[i] = x;

			return ret;
		}
	}

提出情報

提出日時
問題 D - マスと駒と色塗り
ユーザ pythagorean
言語 C# (Mono 3.2.1.0)
得点 0
コード長 11901 Byte
結果 RE
実行時間 335 ms
メモリ 17104 KiB

ジャッジ結果

セット名 Sample Dataset1 Dataset2 Dataset3
得点 / 配点 0 / 0 0 / 35 0 / 40 0 / 25
結果
RE × 3
RE × 11
RE × 15
RE × 36
セット名 テストケース
Sample sample-01.txt, sample-02.txt, sample-03.txt
Dataset1 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt
Dataset2 sample-01.txt, sample-02.txt, sample-03.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt
Dataset3 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, 03-09.txt, 03-10.txt, 03-11.txt, 03-12.txt
ケース名 結果 実行時間 メモリ
01-01.txt RE 207 ms 15312 KiB
01-02.txt RE 249 ms 16760 KiB
01-03.txt RE 278 ms 17104 KiB
01-04.txt RE 211 ms 15364 KiB
01-05.txt RE 141 ms 9568 KiB
01-06.txt RE 137 ms 9648 KiB
01-07.txt RE 139 ms 10152 KiB
01-08.txt RE 161 ms 14212 KiB
01-09.txt RE 226 ms 15840 KiB
02-01.txt RE 141 ms 10136 KiB
02-02.txt RE 141 ms 10064 KiB
02-03.txt RE 140 ms 10040 KiB
02-04.txt RE 137 ms 10156 KiB
02-05.txt RE 140 ms 10048 KiB
02-06.txt RE 139 ms 10188 KiB
02-07.txt RE 194 ms 10156 KiB
02-08.txt RE 139 ms 10144 KiB
02-09.txt RE 139 ms 10144 KiB
02-10.txt RE 136 ms 9644 KiB
02-11.txt RE 136 ms 9640 KiB
02-12.txt RE 139 ms 10148 KiB
03-01.txt RE 335 ms 17064 KiB
03-02.txt RE 332 ms 17064 KiB
03-03.txt RE 333 ms 16944 KiB
03-04.txt RE 254 ms 16788 KiB
03-05.txt RE 287 ms 17092 KiB
03-06.txt RE 327 ms 17044 KiB
03-07.txt RE 322 ms 17060 KiB
03-08.txt RE 306 ms 16952 KiB
03-09.txt RE 300 ms 16968 KiB
03-10.txt RE 164 ms 14084 KiB
03-11.txt RE 321 ms 17036 KiB
03-12.txt RE 322 ms 17036 KiB
sample-01.txt RE 135 ms 9628 KiB
sample-02.txt RE 135 ms 9644 KiB
sample-03.txt RE 136 ms 9636 KiB