結果

問題 No.60 魔法少女
ユーザー yupiteru_kunyupiteru_kun
提出日時 2020-03-16 20:35:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 9,089 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 116,096 KB
実行使用メモリ 127,232 KB
最終ジャッジ日時 2024-05-06 01:09:44
合計ジャッジ時間 6,229 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 66 ms
60,032 KB
testcase_04 AC 381 ms
122,624 KB
testcase_05 WA -
testcase_06 AC 574 ms
127,232 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 569 ms
117,888 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 587 ms
123,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class YUKICODER1
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var K = NN;
            var XYHP = Repeat(0, N).Select(_ => new { X = NN, Y = NN, HP = NN }).ToArray();
            var AXAYWHD = Repeat(0, K).Select(_ => new { AX = NN, AY = NN, W = NN, H = NN, D = NN }).ToArray();
            var seg = new LIB_DualSegTree2D<long>(1501, 1501, 0, (x, y) => x + y);
            foreach (var item in AXAYWHD)
            {
                seg.Update(item.AX + 500, item.AX + 500 + item.W + 1, item.AY + 500, item.AY + 500 + item.H + 1, item.D);
            }
            var ans = 0L;
            foreach (var item in XYHP)
            {
                var dam = seg[item.X + 500, item.Y + 500];
                ans += Max(0, item.HP - dam);
            }
            Console.WriteLine(ans);
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    class LIB_FastIO
    {
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[1024];
        int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        public LIB_FastIODebug() { }
        public override string Scan() => NextString();
        public override long Long() => long.Parse(NextString());
        public override double Double() => double.Parse(NextString());
    }
    class LIB_DualSegTree2D<T> where T : IEquatable<T>
    {
        int xsz;
        int ysz;
        int xheight;
        int yheight;
        T ti;
        Func<T, T, T> f;
        T[,] dat;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_DualSegTree2D(long _xsz, long _ysz, T _ti, Func<T, T, T> _f)
        {
            xsz = ysz = 1;
            xheight = yheight = 0;
            while (xsz < _xsz) { xsz <<= 1; ++xheight; }
            while (ysz < _ysz) { ysz <<= 1; ++yheight; }
            ti = _ti;
            f = _f;
            dat = new T[xsz << 1, ysz << 1];
            for (var i = 0; i < xsz; ++i) for (var j = 0; j < ysz; ++j) dat[i, j] = ti;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long xl, long xr, long yl, long yr, T v)
        {
            if (xl == xr || yl == yr) return;
            if (xr < xl || yr < yl) throw new Exception();
            for (long xli = xsz + xl, xri = xsz + xr; xli < xri; xli >>= 1, xri >>= 1)
            {
                if ((xli & 1) == 1)
                {
                    for (long yli = ysz + yl, yri = ysz + yr; yli < yri; yli >>= 1, yri >>= 1)
                    {
                        if ((yli & 1) == 1) { dat[xli, yli] = f(dat[xli, yli], v); ++yli; }
                        if ((yri & 1) == 1) { --yri; dat[xli, yri] = f(dat[xli, yri], v); }
                    }
                    ++xli;
                }
                if ((xri & 1) == 1)
                {
                    --xri;
                    for (long yli = ysz + yl, yri = ysz + yr; yli < yri; yli >>= 1, yri >>= 1)
                    {
                        if ((yli & 1) == 1) { dat[xri, yli] = f(dat[xri, yli], v); ++yli; }
                        if ((yri & 1) == 1) { --yri; dat[xri, yri] = f(dat[xri, yri], v); }
                    }
                }
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void EvalY(long x, long y)
        {
            if (dat[x, y].Equals(ti)) return;
            dat[x, (y << 1) | 0] = f(dat[x, (y << 1) | 0], dat[x, y]);
            dat[x, (y << 1) | 1] = f(dat[x, (y << 1) | 1], dat[x, y]);
            dat[x, y] = ti;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void EvalX(long x, long y)
        {
            if (dat[x, y].Equals(ti)) return;
            dat[(x << 1) | 0, y] = f(dat[(x << 1) | 0, y], dat[x, y]);
            dat[(x << 1) | 1, y] = f(dat[(x << 1) | 1, y], dat[x, y]);
            dat[x, y] = ti;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Thrust(long x, long y)
        {
            for (var xj = xheight; xj > 0; xj--)
            {
                for (var yj = yheight; yj > 0; yj--)
                {
                    EvalY(x >> xj, y >> yj);
                }
                EvalX(x >> xj, y);
            }
        }
        public T this[long x, long y]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { Thrust(x += xsz, y += ysz); return dat[x, y]; }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            set { Thrust(x += xsz, y += ysz); dat[x, y] = value; }
        }
    }
}
0