QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#648452#8333. Giftucup-team3646#WA 1ms3864kbC++201.5kb2024-10-17 19:03:092024-10-17 19:03:10

Judging History

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

  • [2024-10-17 19:03:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3864kb
  • [2024-10-17 19:03:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin>>N;
    vector<vector<ll>> G(N);
    vector<int> E(N);
    for(int i=0;i<N;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u]++;
        E[v]++;
    }
    vector<int> P=E;
    vector<bool> LOOP(N,1);
    queue<int> Q;
    for(int i=0;i<N;i++){
        if(P[i]==1){
            Q.push(i);
        }
    }
    while(!Q.empty()){
        int p=Q.front();
        Q.pop();
        if(!LOOP[p])continue;
        LOOP[p]=0;
        for(int v:G[p]){
            P[v]--;
            if(P[v]==1){
                Q.push(v);
            }
        }
    }
    vector<int> CNT(N+1,0);
    for(int i=0;i<N;i++)CNT[E[i]]++;
    set<pair<int,int>> seen;
    ll an=0;
    for(int i=0;i<N;i++){
        if(!LOOP[i])continue;
        int u=i;
        for(auto j:G[i]){
            if(LOOP[j]){
                int v=j;
                if(u>v)swap(u,v);
                if(seen.count({u,v}))continue;
                seen.insert({u,v});
                CNT[E[u]]--;
                CNT[E[v]]--;
                CNT[E[u]-1]++;
                CNT[E[v]-1]++;
                an+=N-CNT[4];
                CNT[E[u]]++;
                CNT[E[v]]++;
                CNT[E[u]-1]--;
                CNT[E[v]-1]--;
            }
        }
    }
    cout<<an<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

6
1 2
1 3
1 4
1 5
1 6
2 3

output:

10

result:

ok 1 number(s): "10"

Test #2:

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

input:

3
1 3
3 2
2 1

output:

9

result:

ok 1 number(s): "9"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3820kb

input:

2332
1648 909
1676 2122
1644 1981
1106 1131
1785 239
223 618
335 1662
424 1775
889 1684
1589 52
1406 1747
1600 302
790 2056
1742 464
1706 541
1145 779
2316 833
1645 1439
859 438
1337 136
746 1565
436 1730
2079 2145
1583 1940
917 1549
1863 507
1266 367
1890 2230
13 2113
492 2109
120 1122
815 1111
134...

output:

7723584

result:

wrong answer 1st numbers differ - expected: '5438224', found: '7723584'