結果
問題 | No.5004 Room Assignment |
ユーザー | KumaTachiRen |
提出日時 | 2021-12-01 18:16:25 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 530 ms / 5,000 ms |
コード長 | 5,634 bytes |
コンパイル時間 | 7,382 ms |
実行使用メモリ | 43,496 KB |
スコア | 16,500,815 |
平均クエリ数 | 7628.74 |
最終ジャッジ日時 | 2021-12-01 18:17:31 |
合計ジャッジ時間 | 63,864 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 519 ms
43,220 KB |
testcase_01 | AC | 504 ms
43,068 KB |
testcase_02 | AC | 502 ms
42,668 KB |
testcase_03 | AC | 497 ms
42,876 KB |
testcase_04 | AC | 485 ms
43,160 KB |
testcase_05 | AC | 494 ms
43,132 KB |
testcase_06 | AC | 505 ms
43,256 KB |
testcase_07 | AC | 497 ms
43,148 KB |
testcase_08 | AC | 485 ms
43,400 KB |
testcase_09 | AC | 494 ms
43,476 KB |
testcase_10 | AC | 487 ms
42,996 KB |
testcase_11 | AC | 478 ms
43,172 KB |
testcase_12 | AC | 502 ms
42,676 KB |
testcase_13 | AC | 530 ms
43,200 KB |
testcase_14 | AC | 498 ms
42,696 KB |
testcase_15 | AC | 498 ms
42,660 KB |
testcase_16 | AC | 489 ms
43,028 KB |
testcase_17 | AC | 507 ms
42,848 KB |
testcase_18 | AC | 501 ms
42,976 KB |
testcase_19 | AC | 486 ms
43,064 KB |
testcase_20 | AC | 492 ms
43,020 KB |
testcase_21 | AC | 496 ms
43,072 KB |
testcase_22 | AC | 490 ms
43,044 KB |
testcase_23 | AC | 501 ms
42,888 KB |
testcase_24 | AC | 484 ms
43,108 KB |
testcase_25 | AC | 502 ms
43,312 KB |
testcase_26 | AC | 503 ms
43,164 KB |
testcase_27 | AC | 493 ms
42,988 KB |
testcase_28 | AC | 492 ms
43,200 KB |
testcase_29 | AC | 495 ms
43,212 KB |
testcase_30 | AC | 495 ms
42,660 KB |
testcase_31 | AC | 486 ms
43,028 KB |
testcase_32 | AC | 496 ms
43,016 KB |
testcase_33 | AC | 494 ms
42,876 KB |
testcase_34 | AC | 488 ms
43,204 KB |
testcase_35 | AC | 486 ms
42,952 KB |
testcase_36 | AC | 502 ms
43,064 KB |
testcase_37 | AC | 493 ms
43,076 KB |
testcase_38 | AC | 493 ms
43,164 KB |
testcase_39 | AC | 493 ms
43,108 KB |
testcase_40 | AC | 505 ms
43,120 KB |
testcase_41 | AC | 512 ms
42,564 KB |
testcase_42 | AC | 497 ms
42,844 KB |
testcase_43 | AC | 493 ms
43,048 KB |
testcase_44 | AC | 495 ms
43,140 KB |
testcase_45 | AC | 494 ms
42,628 KB |
testcase_46 | AC | 494 ms
42,988 KB |
testcase_47 | AC | 501 ms
43,168 KB |
testcase_48 | AC | 504 ms
42,828 KB |
testcase_49 | AC | 507 ms
43,140 KB |
testcase_50 | AC | 493 ms
43,128 KB |
testcase_51 | AC | 511 ms
43,108 KB |
testcase_52 | AC | 494 ms
43,068 KB |
testcase_53 | AC | 488 ms
43,428 KB |
testcase_54 | AC | 497 ms
42,880 KB |
testcase_55 | AC | 510 ms
42,884 KB |
testcase_56 | AC | 495 ms
42,992 KB |
testcase_57 | AC | 493 ms
43,420 KB |
testcase_58 | AC | 501 ms
43,016 KB |
testcase_59 | AC | 501 ms
42,948 KB |
testcase_60 | AC | 506 ms
43,496 KB |
testcase_61 | AC | 491 ms
42,952 KB |
testcase_62 | AC | 499 ms
43,192 KB |
testcase_63 | AC | 495 ms
43,368 KB |
testcase_64 | AC | 488 ms
42,880 KB |
testcase_65 | AC | 502 ms
43,096 KB |
testcase_66 | AC | 497 ms
43,000 KB |
testcase_67 | AC | 513 ms
42,816 KB |
testcase_68 | AC | 498 ms
42,916 KB |
testcase_69 | AC | 494 ms
43,088 KB |
testcase_70 | AC | 486 ms
42,984 KB |
testcase_71 | AC | 489 ms
42,788 KB |
testcase_72 | AC | 498 ms
42,976 KB |
testcase_73 | AC | 505 ms
43,108 KB |
testcase_74 | AC | 487 ms
43,012 KB |
testcase_75 | AC | 520 ms
43,124 KB |
testcase_76 | AC | 488 ms
43,012 KB |
testcase_77 | AC | 489 ms
43,132 KB |
testcase_78 | AC | 491 ms
42,796 KB |
testcase_79 | AC | 486 ms
43,172 KB |
testcase_80 | AC | 494 ms
43,168 KB |
testcase_81 | AC | 487 ms
43,192 KB |
testcase_82 | AC | 488 ms
43,228 KB |
testcase_83 | AC | 487 ms
43,200 KB |
testcase_84 | AC | 503 ms
42,784 KB |
testcase_85 | AC | 505 ms
42,976 KB |
testcase_86 | AC | 496 ms
42,988 KB |
testcase_87 | AC | 494 ms
43,084 KB |
testcase_88 | AC | 488 ms
43,468 KB |
testcase_89 | AC | 497 ms
43,040 KB |
testcase_90 | AC | 488 ms
42,936 KB |
testcase_91 | AC | 507 ms
43,172 KB |
testcase_92 | AC | 493 ms
43,136 KB |
testcase_93 | AC | 489 ms
43,212 KB |
testcase_94 | AC | 501 ms
42,824 KB |
testcase_95 | AC | 489 ms
42,800 KB |
testcase_96 | AC | 499 ms
42,980 KB |
testcase_97 | AC | 503 ms
43,232 KB |
testcase_98 | AC | 513 ms
43,316 KB |
testcase_99 | AC | 499 ms
42,920 KB |
コンパイルメッセージ
.NET 向け Microsoft (R) Build Engine バージョン 16.9.0+5e4b48a27 Copyright (C) Microsoft Corporation.All rights reserved. Determining projects to restore... Restored /home/judge/data/code/main.csproj (in 150 ms). /home/judge/data/code/Main.cs(125,10): warning CS0414: フィールド 'Solver.inf' が割り当てられていますが、値は使用されていません [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net5.0/linux-x64/main.dll main -> /home/judge/data/code/bin/Release/net5.0/linux-x64/publish/
ソースコード
using System; using System.Linq; using System.Numerics; using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; using System.Timers; using N = System.Int64; static class Program { static public void Main(string[] args) { Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); var solver = new Solver(); solver.Solve(); Console.Out.Flush(); } } public class Solver { public void Solve() { int t = ri, r = ri; var uf = new UnionFind(5400); int p = 0; for (int timer = 0; timer < t; timer++) { int n = ri; int s; var ans = new List<string>(); for (int i = 0; i < n; i++) { s = ri; uf.SetData(p + i, s); for (int j = 0; j < p + i; j++) { if (uf.Size(j) < 4 && uf.GetNewValue(j, s, timer) - uf.GetNowValue(j) >= 1) { uf.Unite(j, p + i, timer); ans.Add($"{j + 1} {p + i + 1}"); break; } } } if (ans.Count == 0) Write(0); else Write($"{ans.Count}\n{string.Join("\n", ans)}"); Console.Out.Flush(); p += n; } } public class UnionFind { private int _len; private int[] _par; private int[] _size; private int[] _skill_min; private int[] _skill_max; private int[] _tick_sum; private int[] _score_e; public UnionFind(int len) { _len = len; _par = new int[len]; _size = new int[len]; for (int i = 0; i < len; i++) { _par[i] = i; _size[i] = 1; } _skill_min = new int[len]; _skill_max = new int[len]; _tick_sum = new int[len]; _score_e = new int[len]; } public void SetData(int x, int s) { _skill_min[x] = s; _skill_max[x] = s; } public int GetNowValue(int x) { int rx = Root(x); int k = _size[rx] * (_size[rx] - 1) / 2; int skill = _skill_max[rx] - _skill_min[rx]; return Math.Max(0, k * (200 - skill * skill) - _score_e[rx]); } public int GetNewValue(int x, int s, int t) { int rx = Root(x); int k = _size[rx] * (_size[rx] + 1) / 2; int skill = Math.Max(_skill_max[rx], s) - Math.Min(_skill_min[rx], s); return Math.Max(0, k * (200 - skill * skill) - (_score_e[rx] + _tick_sum[rx] - _size[rx] * t)); } public int Root(int x) { if (_par[x] == x) return x; return _par[x] = Root(_par[x]); } public int Size(int x) { if (_par[x] == x) return _size[x]; return _size[x] = _size[Root(x)]; } public bool IsSame(int x, int y) { return Root(x) == Root(y); } public void Unite(int x, int y, int t) { int rx = Root(x); int ry = Root(y); if (rx != ry) { _score_e[rx] += _tick_sum[rx] - _size[rx] * t; _tick_sum[rx] += t; _par[ry] = rx; _size[rx] += _size[ry]; _skill_max[rx] = Math.Max(_skill_max[rx], _skill_max[ry]); _skill_min[rx] = Math.Min(_skill_min[rx], _skill_min[ry]); } } } //int inf = 1 << 30; long inf = (long)1 << 60; int ri { get { return (int)sc.Integer(); } } long rl { get { return sc.Integer(); } } double rd { get { return sc.Double(); } } string rs { get { return sc.Scan(); } } public StreamScanner sc = new StreamScanner(Console.OpenStandardInput()); void Write<T>(T t) { Console.WriteLine(t.ToString()); } void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); } void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); } void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); } } public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } private readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } private 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++]; } public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public long Integer() { 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'; } } public double Double() { return double.Parse(Scan()); } }