結果
問題 | No.2418 情報通だよ!Nafmoくん |
ユーザー | maple_1016 |
提出日時 | 2023-08-12 13:58:58 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 1,535 bytes |
コンパイル時間 | 2,840 ms |
コンパイル使用メモリ | 200,296 KB |
実行使用メモリ | 18,136 KB |
最終ジャッジ日時 | 2024-04-30 04:38:51 |
合計ジャッジ時間 | 5,506 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 135 ms
16,584 KB |
testcase_04 | AC | 66 ms
13,952 KB |
testcase_05 | AC | 61 ms
7,936 KB |
testcase_06 | AC | 105 ms
15,576 KB |
testcase_07 | AC | 64 ms
7,040 KB |
testcase_08 | AC | 129 ms
18,136 KB |
testcase_09 | AC | 81 ms
9,344 KB |
testcase_10 | AC | 125 ms
15,108 KB |
testcase_11 | AC | 111 ms
14,228 KB |
testcase_12 | AC | 81 ms
12,272 KB |
testcase_13 | AC | 31 ms
6,656 KB |
testcase_14 | AC | 63 ms
9,728 KB |
testcase_15 | AC | 45 ms
5,376 KB |
testcase_16 | AC | 106 ms
11,776 KB |
testcase_17 | AC | 24 ms
5,376 KB |
testcase_18 | AC | 82 ms
13,588 KB |
testcase_19 | AC | 58 ms
13,056 KB |
testcase_20 | AC | 48 ms
5,376 KB |
testcase_21 | AC | 40 ms
7,936 KB |
testcase_22 | AC | 31 ms
5,376 KB |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #define rep(i,n) for(ll i=0;i<(n);++i) #define reps(i,n) for(ll i=1;i<=(n);++i) #define repr(i,n) for(ll i=2;i*i<=(n);++i) #define ll long long #define all(x) (x).begin(),(x).end() #define sz(x) ((string)(x).size()) #define pb push_back #define pob pop_back() #define MMod (ll)1000000007 #define mmod (ll)998244353 #define setp(x) setprecision((ll)(x)) #define INF (ll)(1000000000000000000) #define mp make_pair using namespace std; using pii=pair<int, int>; using pll=pair<ll,ll>; using vi=vector<int>; using vc=vector<char>; using vb=vector<bool>; using vl=vector<long long>; using vvi=vector<vi>; using vvl=vector<vl>; using vvc=vector<vc>; using vvb=vector<vb>; using vpi=vector<pii>; using vpl=vector<pair<ll,ll>>; using vs=vector<string>; using pqi=priority_queue<int>; vpi fs={mp(1,0),mp(-1,0),mp(0,1),mp(0,-1)}; const ll inf=1e18; int main(){ int n,m; cin>>n>>m; vvi p(2*n+1); rep(i,m){ int a,b; cin>>a>>b; p[a].pb(b); p[b].pb(a); } vi d(2*n+1,-1); int k=0; queue<int> bfs; map<int,int> aa; reps(i,2*n){ if(d[i]!=-1) continue; bfs.push(i); d[i]=k; aa[k]++; while(!bfs.empty()){ int a=bfs.front(); bfs.pop(); rep(i,p[a].size()){ if(d[p[a][i]]==-1){ bfs.push(p[a][i]); d[p[a][i]]=k; aa[k]++; } } } k++; } int count=0; rep(i,k) count+=aa[i]%2; cout<<count/2<<endl; return 0; }