結果
| 問題 |
No.513 宝探し2
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2017-05-18 19:43:08 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,220 bytes |
| コンパイル時間 | 2,171 ms |
| コンパイル使用メモリ | 112,304 KB |
| 実行使用メモリ | 43,720 KB |
| 平均クエリ数 | 43.25 |
| 最終ジャッジ日時 | 2024-07-16 13:45:49 |
| 合計ジャッジ時間 | 3,763 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using System.Net;
public class Program
{
public void Proc() {
Reader.IsDebug = false;
try {
int posX = GetX(0, 100000);
int posY = GetY(0, 100000);
GetPos(posX, posY);
} catch(Exception e) {
}
}
Dictionary<int, Dictionary<int, int>> dic = new Dictionary<int, Dictionary<int, int>>();
private int GetY(int min, int max) {
int idx1 = min + ((max-min)/3);
int idx2 = min + ((max-min)*2/3);
int minPos = GetPos(0,min);
int idx1Pos = GetPos(0,idx1);
int idx2Pos = GetPos(0,idx2);
int maxPos = GetPos(0,max);
int[] arr = new int[]{minPos, idx1Pos, idx2Pos, maxPos};
if(max-min<=3) {
if(arr.Min() == minPos) {
return min;
} else if(arr.Min() == idx1Pos) {
return idx1;
} else if(arr.Min() == idx2Pos) {
return idx2;
} else {
return max;
}
}
if(arr.Min() == minPos) {
return GetX(min, idx1);
} else if(arr.Min() == idx1Pos) {
return GetX(min, idx2);
} else if(arr.Min() == idx2Pos) {
return GetX(idx1, maxPos);
} else {
return GetX(idx2, max);
}
}
private int GetX(int min, int max) {
if(max-min<=1) {
int num1 = GetPos(min, 0);
int num2 = GetPos(max, 0);
if(num1<=num2) {
return min;
} else {
return max;
}
}
int idx1 = min + ((max-min)/3);
int idx2 = min + ((max-min)*2/3);
int minPos = GetPos(min, 0);
int idx1Pos = GetPos(idx1, 0);
int idx2Pos = GetPos(idx2, 0);
int maxPos = GetPos(max, 0);
int[] arr = new int[]{minPos, idx1Pos, idx2Pos, maxPos};
if(max-min<=3) {
if(arr.Min() == minPos) {
return min;
} else if(arr.Min() == idx1Pos) {
return idx1;
} else if(arr.Min() == idx2Pos) {
return idx2;
} else {
return max;
}
}
if(arr.Min() == minPos) {
return GetX(min, idx1);
} else if(arr.Min() == idx1Pos) {
return GetX(min, idx2);
} else if(arr.Min() == idx2Pos) {
return GetX(idx1, maxPos);
} else {
return GetX(idx2, max);
}
}
private int GetPos(int x, int y) {
if(!dic.ContainsKey(x)) {
dic.Add(x, new Dictionary<int, int>());
}
if(dic[x].ContainsKey(y)) {
return dic[x][y];
}
Console.WriteLine(x + " " + y);
int ans = int.Parse(Reader.ReadLine());
if(ans == 0) {
throw new Exception();
}
dic[x][y] = ans;
return ans;
}
public class Reader {
public static bool IsDebug = true;
private static System.IO.StringReader SReader;
private static string InitText = @"
19 57
9
5 16 48 144 432 1296 3888 11664 34992
";
public static string ReadLine() {
if(IsDebug) {
if(SReader == null) {
SReader = new System.IO.StringReader(InitText.Trim());
}
return SReader.ReadLine();
} else {
return Console.ReadLine();
}
}
}
public static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
14番