結果
| 問題 |
No.2962 Sum Bomb Bomber
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-30 16:38:53 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 225 ms / 2,000 ms |
| コード長 | 1,754 bytes |
| コンパイル時間 | 12,104 ms |
| コンパイル使用メモリ | 168,560 KB |
| 実行使用メモリ | 46,936 KB |
| 平均クエリ数 | 171.94 |
| 最終ジャッジ日時 | 2024-12-30 16:39:23 |
| 合計ジャッジ時間 | 28,724 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 64 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (115 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static long NN => long.Parse(ReadLine());
public static void Main()
{
Solve();
}
static void Solve()
{
var n = NN;
var max = 100_000_001L;
var left = -max;
var right = max;
var cl = 0L;
var cr = 0L;
var clval = 0L;
var crval = 0L;
while (right - left > 2)
{
cl = (left * 2 + right) / 3;
clval = CalcX(cl);
cr = (left + right * 2) / 3;
crval = CalcX(cr);
if (clval < crval) right = cr;
else left = cl;
}
dic = new Dictionary<long, long>();
var bottom = -max;
var top = max;
var cb = 0L;
var ct = 0L;
var cbval = 0L;
var ctval = 0L;
while (top - bottom > 2)
{
cb = (bottom * 2 + top) / 3;
cbval = CalcY(cb);
ct = (bottom + top * 2) / 3;
ctval = CalcY(ct);
if (cbval < ctval) top = ct;
else bottom = cb;
}
WriteLine($"2 {(clval < crval ? cl : cr)} {(cbval < ctval ? cb : ct)}");
}
static Dictionary<long, long> dic = new Dictionary<long, long>();
static long CalcX(long x)
{
if (dic.ContainsKey(x)) return dic[x];
WriteLine($"1 {x} 0");
var ans = NN;
dic[x] = ans;
return ans;
}
static long CalcY(long y)
{
if (dic.ContainsKey(y)) return dic[y];
WriteLine($"1 0 {y}");
var ans = NN;
dic[y] = ans;
return ans;
}
}