QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261432#7755. Game on a ForestSSH#WA 3ms28652kbC++171.2kb2023-11-22 21:36:212023-11-22 21:36:22

Judging History

你现在查看的是最新测评结果

  • [2023-11-22 21:36:22]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:28652kb
  • [2023-11-22 21:36:21]
  • 提交

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] % 2 == 0)cnt++;
        if(d[i] % 2 == 1)cnt1++;
    }
    if((n + m) % 2){
        cout << m << "\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: 3ms
memory: 28652kb

input:

3 1
1 2

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 27900kb

input:

4 3
1 2
2 3
3 4

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 27620kb

input:

100000 1
4647 17816

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 27512kb

input:

100000 2
64075 72287
63658 66936

output:

4

result:

wrong answer 1st numbers differ - expected: '0', found: '4'