結果
問題 | No.5004 Room Assignment |
ユーザー | KumaTachiRen |
提出日時 | 2021-12-03 22:42:23 |
言語 | C# (.NET 8.0.203) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,904 bytes |
コンパイル時間 | 13,131 ms |
実行使用メモリ | 67,724 KB |
スコア | 0 |
最終ジャッジ日時 | 2021-12-03 22:42:51 |
合計ジャッジ時間 | 26,556 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
testcase_73 | -- | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
testcase_94 | -- | - |
testcase_95 | -- | - |
testcase_96 | -- | - |
testcase_97 | -- | - |
testcase_98 | -- | - |
testcase_99 | -- | - |
コンパイルメッセージ
.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 299 ms). /home/judge/data/code/Main.cs(132,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; var s = new int[5400]; for (int timer = 0; timer < t; timer++) { int n = ri; var ans = new List<string>(); for (int i = 0; i < n; i++) { s[p + i] = ri; uf.SetData(p + i, s[p + i]); } if (timer > t * 5 / 100) { for (int i = 0; i < p + n; i++) { if (uf.Size(i) > 1) continue; for (int j = 0; j < i; j++) { if (uf.Size(j) < 4 && uf.GetNewValue(j, s[i], timer) - uf.GetNowValue(j) >= (t - 1 - timer)) { uf.Unite(j, p + i, timer); ans.Add($"{j + 1} {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()); } }