QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#261367 | #7755. Game on a Forest | SSH# | WA | 7ms | 28404kb | C++17 | 1.2kb | 2023-11-22 20:39:13 | 2023-11-22 20:39:13 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve();
signed main(){
cin.sync_with_stdio(0);
cin.tie(0);
int T = 1;
//cin >> T;
while(T--){
solve();
}
return 0;
}
#define N 1000100
vector<int> g[N];
int vis[N], ns[N], es[N], fa[N], d[N];
pair<int,int> dfs(int u, int ff){
vis[u] = 1;
fa[u] = ff;
pair<int,int> res = {1, g[u].size()};
for(int v:g[u]){
if(vis[v] == 0){
auto [x,y] = dfs(v, ff);
res.first += x;
res.second += y;
}
}
return res;
}
void solve(){
int n, m;
cin >> n >> m;
//vector<pair<int,int>> edgs(m + 1);
for(int i = 0;i < m;i++){
int u, v;
cin >> u >> v;
//edgs[i + 1] = {u, v};
g[u].push_back(v);
g[v].push_back(u);
d[v]++;
d[u]++;
}
int cnt = 0, cnt1 = 0;;
for(int i = 1;i <= n;i++){
if(d[i] == 0)cnt++;
if(d[i] == 1)cnt1++;
}
if((n + m) % 2){
cout << m + cnt << "\n";
}
else{
cout << cnt1 << "\n";
//cout << m + cnt << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 7ms
memory: 27380kb
input:
3 1 1 2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 27796kb
input:
4 3 1 2 2 3 3 4
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 28404kb
input:
100000 1 4647 17816
output:
99999
result:
wrong answer 1st numbers differ - expected: '1', found: '99999'