結果
問題 | No.5004 Room Assignment |
ユーザー | KumaTachiRen |
提出日時 | 2021-12-01 17:26:12 |
言語 | C# (.NET 8.0.203) |
結果 |
RE
|
実行時間 | - |
コード長 | 5,269 bytes |
コンパイル時間 | 11,988 ms |
実行使用メモリ | 46,640 KB |
スコア | 0 |
平均クエリ数 | 48.61 |
最終ジャッジ日時 | 2021-12-01 17:27:18 |
合計ジャッジ時間 | 65,507 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | RE | - |
testcase_89 | RE | - |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | RE | - |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | RE | - |
testcase_96 | RE | - |
testcase_97 | RE | - |
testcase_98 | RE | - |
testcase_99 | RE | - |
コンパイルメッセージ
.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 243 ms). /home/judge/data/code/Main.cs(118,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.SetSkill(p + i, s); for (int j = 0; j < p + i; j++) { if (uf.Size(j) < 4 && uf.GetNowValue(j) < uf.GetNewValue(j, s)) { uf.Unite(j, p + i); ans.Add($"{j + 1} {p + i + 1}"); } } } 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; 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]; } public void SetSkill(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)); } public int GetNewValue(int x, int s) { 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)); } 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 rx = Root(x); int ry = Root(y); if (rx != ry) { _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()); } }