結果
| 問題 | No.2319 Friends+ |
| コンテスト | |
| ユーザー |
👑 amentorimaru
|
| 提出日時 | 2023-03-18 00:23:41 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 1,052 ms / 3,000 ms |
| コード長 | 1,616 bytes |
| 記録 | |
| コンパイル時間 | 9,705 ms |
| コンパイル使用メモリ | 167,604 KB |
| 実行使用メモリ | 262,780 KB |
| 最終ジャッジ日時 | 2024-09-18 12:42:58 |
| 合計ジャッジ時間 | 50,930 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (92 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;
class Program
{
static void Main(string[] args)
{
int N, M, Q;
int[] P;
long[,] PB;
long[,] FB;
string[] input1 = Console.ReadLine().Split();
N = int.Parse(input1[0]);
M = int.Parse(input1[1]);
P = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 0; i < N; i++)
P[i]--;
PB = new long[N, N / 64 + 1];
for (int i = 0; i < N; i++)
{
PB[P[i], i / 64] ^= (1L << (i % 64));
}
FB = new long[N, N / 64 + 1];
for (int i = 0; i < M; i++)
{
string[] input2 = Console.ReadLine().Split();
int A = int.Parse(input2[0]) - 1;
int B = int.Parse(input2[1]) - 1;
FB[A, B / 64] ^= (1L << (B % 64));
FB[B, A / 64] ^= (1L << (A % 64));
}
Q = int.Parse(Console.ReadLine());
for (int i = 0; i < Q; i++)
{
string[] input3 = Console.ReadLine().Split();
int X = int.Parse(input3[0]) - 1;
int Y = int.Parse(input3[1]) - 1;
bool f = false;
if(P[X]!=P[Y]){
for (int j=0; j<N/64+1;j++){
f|=(FB[X,j]&PB[P[Y],j])!=0;
}
}
if (f)
{
Console.WriteLine("Yes");
PB[P[X],X/64]^=(1L << (X%64));
PB[P[Y],X/64]^=(1L << (X%64));
P[X]=P[Y];
}
else
{
Console.WriteLine("No");
}
}
}
}
amentorimaru