結果

問題 No.2319 Friends+
ユーザー umezoumezo
提出日時 2024-04-11 00:36:36
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 412 ms / 3,000 ms
コード長 864 bytes
コンパイル時間 3,491 ms
コンパイル使用メモリ 277,920 KB
実行使用メモリ 101,248 KB
最終ジャッジ日時 2024-04-11 00:36:59
合計ジャッジ時間 17,985 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 206 ms
100,992 KB
testcase_03 AC 174 ms
101,120 KB
testcase_04 AC 225 ms
101,248 KB
testcase_05 AC 159 ms
101,164 KB
testcase_06 AC 172 ms
101,120 KB
testcase_07 AC 388 ms
101,120 KB
testcase_08 AC 317 ms
100,992 KB
testcase_09 AC 412 ms
101,120 KB
testcase_10 AC 337 ms
101,120 KB
testcase_11 AC 330 ms
101,248 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 241 ms
101,100 KB
testcase_19 AC 263 ms
101,124 KB
testcase_20 AC 188 ms
101,120 KB
testcase_21 AC 184 ms
101,104 KB
testcase_22 AC 186 ms
100,992 KB
testcase_23 AC 217 ms
101,120 KB
testcase_24 AC 261 ms
101,220 KB
testcase_25 AC 201 ms
101,120 KB
testcase_26 AC 199 ms
101,192 KB
testcase_27 AC 201 ms
101,208 KB
testcase_28 AC 189 ms
101,248 KB
testcase_29 AC 190 ms
101,200 KB
testcase_30 AC 267 ms
101,120 KB
testcase_31 AC 185 ms
101,100 KB
testcase_32 AC 186 ms
101,120 KB
testcase_33 AC 181 ms
101,208 KB
testcase_34 AC 181 ms
101,248 KB
testcase_35 AC 182 ms
101,112 KB
testcase_36 AC 305 ms
101,068 KB
testcase_37 AC 157 ms
101,240 KB
testcase_38 AC 160 ms
101,104 KB
testcase_39 AC 162 ms
101,116 KB
testcase_40 AC 164 ms
101,128 KB
testcase_41 AC 169 ms
101,248 KB
testcase_42 AC 185 ms
101,248 KB
testcase_43 AC 194 ms
100,992 KB
testcase_44 AC 167 ms
101,248 KB
testcase_45 AC 158 ms
101,124 KB
testcase_46 AC 150 ms
101,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>; //B(n,V<int>(n))
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,m;
  cin>>n>>m;
  V<int> P(n);
  V<bitset<20000>> wor(n),fri(n); 
  rep(i,n){
    cin>>P[i];
    P[i]--;
    wor[P[i]].set(i);
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    fri[a].set(b);
    fri[b].set(a);
  }
  int q;
  cin>>q;
  rep(i,q){
    int x,y;
    cin>>x>>y;
    x--,y--;
    if(P[x]==P[y]){
      cout<<"No\n";
    }
    else{
      if((wor[P[y]]&fri[x]).any()){
        cout<<"Yes\n";
        wor[P[x]].reset(x);
        P[x]=P[y];
        wor[P[x]].set(x);
      }
      else cout<<"No\n";
    }
  }
  
  return 0;
}
0