結果

問題 No.2319 Friends+
ユーザー KudeKude
提出日時 2023-05-26 22:37:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 319 ms / 3,000 ms
コード長 1,337 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 224,940 KB
実行使用メモリ 101,532 KB
最終ジャッジ日時 2023-08-26 12:46:03
合計ジャッジ時間 13,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,528 KB
testcase_01 AC 2 ms
5,396 KB
testcase_02 AC 148 ms
55,768 KB
testcase_03 AC 145 ms
55,668 KB
testcase_04 AC 140 ms
55,732 KB
testcase_05 AC 142 ms
55,676 KB
testcase_06 AC 146 ms
55,780 KB
testcase_07 AC 319 ms
101,220 KB
testcase_08 AC 316 ms
101,276 KB
testcase_09 AC 311 ms
101,228 KB
testcase_10 AC 309 ms
101,216 KB
testcase_11 AC 305 ms
101,348 KB
testcase_12 AC 3 ms
8,284 KB
testcase_13 AC 3 ms
8,260 KB
testcase_14 AC 3 ms
8,452 KB
testcase_15 AC 3 ms
8,280 KB
testcase_16 AC 3 ms
8,424 KB
testcase_17 AC 2 ms
5,424 KB
testcase_18 AC 181 ms
52,612 KB
testcase_19 AC 218 ms
101,284 KB
testcase_20 AC 157 ms
52,600 KB
testcase_21 AC 158 ms
52,768 KB
testcase_22 AC 160 ms
52,544 KB
testcase_23 AC 179 ms
77,180 KB
testcase_24 AC 171 ms
64,904 KB
testcase_25 AC 164 ms
58,804 KB
testcase_26 AC 165 ms
56,640 KB
testcase_27 AC 165 ms
54,700 KB
testcase_28 AC 171 ms
54,592 KB
testcase_29 AC 161 ms
54,592 KB
testcase_30 AC 156 ms
52,540 KB
testcase_31 AC 156 ms
52,552 KB
testcase_32 AC 155 ms
52,600 KB
testcase_33 AC 163 ms
52,600 KB
testcase_34 AC 160 ms
52,604 KB
testcase_35 AC 159 ms
52,592 KB
testcase_36 AC 223 ms
101,220 KB
testcase_37 AC 117 ms
58,316 KB
testcase_38 AC 146 ms
101,212 KB
testcase_39 AC 148 ms
101,532 KB
testcase_40 AC 147 ms
101,240 KB
testcase_41 AC 151 ms
101,212 KB
testcase_42 AC 148 ms
101,380 KB
testcase_43 AC 154 ms
101,476 KB
testcase_44 AC 147 ms
101,388 KB
testcase_45 AC 139 ms
101,436 KB
testcase_46 AC 126 ms
58,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr int M = 20000;
using BS = bitset<M>;

BS c2p[M];
BS adj[M];

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  VI c(n);
  rep(i, n) cin >> c[i], c[i]--, c2p[c[i]][i] = true;
  rep(_, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a][b] = adj[b][a] = true;
  }
  int q;
  cin >> q;
  while(q--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (c[x] != c[y] && (adj[x] & c2p[c[y]]).any()) {
      cout << "Yes\n";
      c2p[c[x]][x] = false;
      c[x] = c[y];
      c2p[c[x]][x] = true;
    } else {
      cout << "No\n";
    }
  }
}
0