結果
問題 | No.2290 UnUnion Find |
ユーザー | pirata |
提出日時 | 2023-05-05 22:32:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,264 bytes |
コンパイル時間 | 4,611 ms |
コンパイル使用メモリ | 262,428 KB |
実行使用メモリ | 8,960 KB |
最終ジャッジ日時 | 2024-05-02 17:20:47 |
合計ジャッジ時間 | 9,356 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
8,832 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 269 ms
5,376 KB |
testcase_03 | AC | 173 ms
5,376 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using Graph = vector<vector<int> >; using mint = modint998244353; const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e+18; #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP2(i, s, n) for (int i = (s); i < (int)(n); i++) #define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} #define ALL(x) x.begin(),x.end() #define VI vector<int> #define VL vector<ll> #define VC vector<char> #define VVI vector<vector<int> > #define VVL vector<vector<ll> > #define VVC vector<vector<char> > #define VPII vector<pair<int,int> > #define VPLL vector<pair<ll,ll> > template <class T> inline void printVec(std::vector<T> v){ REP(i,v.size()){ if(i) std::cout << " "; std::cout << v[i]; } std::cout << std::endl; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N,Q; cin >> N >> Q; dsu d(N); REP(i,Q){ int q; cin >> q; if(q == 1){ int u,v; cin >> u >> v; u--;v--; d.merge(u,v); } else{ int v; cin >> v; v--; if(d.size(v) == N){ cout << -1 << endl; continue; } REP(i,N){ if(!d.same(v,i)){ cout << i + 1 << endl; break; } } } } }