結果
| 問題 |
No.1544 [Cherry 2nd Tune C] Synchroscope
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2021-06-12 07:05:38 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,370 bytes |
| コンパイル時間 | 3,782 ms |
| コンパイル使用メモリ | 106,752 KB |
| 実行使用メモリ | 509,080 KB |
| 最終ジャッジ日時 | 2024-12-15 20:26:44 |
| 合計ジャッジ時間 | 99,257 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 TLE * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;
public class P
{
public int aa { get; set; }
public int bb { get; set; }
}
public class Hello
{
public static int n, m;
static void Main()
{
string[] line = Console.ReadLine().Trim().Split(' ');
n = int.Parse(line[0]);
m = int.Parse(line[1]);
line = Console.ReadLine().Trim().Split(' ');
var a = Array.ConvertAll(line, int.Parse);
line = Console.ReadLine().Trim().Split(' ');
var b = Array.ConvertAll(line, int.Parse);
var ps = new List<P>();
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (a[i] == b[j]) ps.Add(new P { aa = i, bb = j });
getAns(ps);
}
static void getAns(List<P> ps)
{
var ans = int.MaxValue;
if (ps.Count() == 0) { Console.WriteLine(-1); return; }
var tmax = Max(n, m);
foreach (var x in ps)
{
for (int L = 0; L <= tmax; L++)
for (int k = 0; k <= tmax; k++)
{
if ((m * L + x.bb - x.aa) % n == 0)
{
var p = m * L + x.bb;
ans = Min(ans, p);
}
}
}
Console.WriteLine(ans + 1);
}
}
bluemegane