結果

問題 No.2357 Guess the Function
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-16 23:58:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 233 ms / 1,000 ms
コード長 2,434 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 68,684 KB
実行使用メモリ 45,440 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-08-16 23:58:12
合計ジャッジ時間 6,182 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
43,212 KB
testcase_01 AC 224 ms
44,936 KB
testcase_02 AC 221 ms
43,316 KB
testcase_03 AC 223 ms
42,928 KB
testcase_04 AC 226 ms
44,700 KB
testcase_05 AC 227 ms
45,016 KB
testcase_06 AC 227 ms
45,036 KB
testcase_07 AC 233 ms
45,440 KB
testcase_08 AC 227 ms
45,052 KB
testcase_09 AC 232 ms
45,292 KB
testcase_10 AC 232 ms
45,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        for (var x = 1; x <= 100; ++x)
        {
            var dic = new List<(int a, int b)>[100];
            for (var i = 0; i < dic.Length; ++i) dic[i] = new List<(int a, int b)>();
            for (var a = 0; a < 100; ++a) for (var b = a + 1; b <= 100; ++b)
            {
                dic[(x + a) % b].Add((a, b));
            }
            var flg = true;
            var ylist = new int[100];
            for (var xa = 0; xa < dic.Length; ++xa)
            {
                for (var y = 1; y <= 100; ++y)
                {
                    var yd = new List<(int a, int b)>[100];
                    for (var i = 0; i < yd.Length; ++i) yd[i] = new List<(int a, int b)>();
                    foreach (var di in dic[xa])
                    {
                        yd[(y + di.a) % di.b].Add(di);
                    }
                    var countmax = 0;
                    for (var i = 0; i < yd.Length; ++i) countmax = Math.Max(countmax, yd[i].Count);
                    if (countmax < 2)
                    {
                        ylist[xa] = y;
                        break;
                    }
                }
                if (ylist[xa] == 0)
                {
                    flg = false;
                    break;
                }
            }
            if (flg)
            {
                WriteLine($"? {x}");
                var ans1 = NN;
                WriteLine($"? {ylist[ans1]}");
                var ans2 = NN;
                var yd = new List<(int a, int b)>[100];
                for (var i = 0; i < yd.Length; ++i) yd[i] = new List<(int a, int b)>();
                foreach (var di in dic[ans1])
                {
                    if ((ylist[ans1] + di.a) % di.b == ans2)
                    {
                        WriteLine($"! {di.a} {di.b}");
                        return;
                    }
                }
            }
        }
    }
}
0