QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#734762#9474. Colored NodesvisionWA 379ms16360kbC++201.7kb2024-11-11 14:58:202024-11-11 14:58:24

Judging History

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

  • [2024-11-11 14:58:24]
  • 评测
  • 测评结果:WA
  • 用时:379ms
  • 内存:16360kb
  • [2024-11-11 14:58:20]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define lson k<<1
#define rson (k<<1)|1
#define debug cout<<666<<endl;
using namespace std;
const int N=1e6+5;
vector<int>v[N];
int col[N];
void vision()
{
    int n,m;
    while(cin>>n>>m){
        for(int i=1;i<=n;i++){
            col[i]=i;
            v[i].clear();
        }
        for(int i=1;i<=m;i++){
            int x,y;
            cin>>x>>y;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        for(int i=1;i<=n;i++){
            for(auto it:v[i]){
                col[it]=col[i];
            }
        }
        for(int i=1;i<=n;i++){
            for(auto it:v[i]){
                col[it]=col[i];
            }
        }
        map<int,int>mp;
        for(int i=1;i<=n;i++){
            mp[col[i]]++;
        }
        for(auto it:mp){
            mp[it.first]=it.second*n;
        }
        for(int i=1;i<n;i++){
            int tmp=n-i;
            for(auto it:v[i]){
                if(col[it]==col[i])continue;
                mp[col[it]]-=tmp;
                mp[col[i]]+=tmp;
                col[it]=col[i];
            }
        }
        vector<int>vv;
        for(auto it:mp){
            vv.push_back(it.second);
        }
        sort(vv.begin(),vv.end(),greater<int>());
        for(auto it:vv){
            // cout<<it<<" ";
            double now=(double)it/(double)(n);
            cout<<fixed<<setprecision(6)<<now<<"\n";
        }
    }
    return ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    // cin>>t;
    while(t--){
        vision();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3764kb

input:

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

output:

3.000000
2.000000
2.800000
2.200000

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 379ms
memory: 16360kb

input:

10 10
1 2
2 3
3 4
4 5
5 6
10 7
7 8
8 9
9 10
6 9
10 10
6 5
5 3
3 4
4 2
6 1
10 7
7 8
8 9
9 10
6 10
4 3
1 2
2 3
3 4
8 12
4 7
7 6
7 2
7 3
2 5
5 7
4 3
7 2
7 6
3 4
4 5
4 8
100 100
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25...

output:

5.600000
4.400000
6.000000
4.000000
4.000000
7.000000
1.000000
51.540000
3.450000
3.370000
3.030000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
2.970000
21.660000
15.660000
5.290000
3.930000
3.450000
3.430000
2.970000
2.970000
2.970000
...

result:

wrong answer 9th lines differ - expected: '3.028750', found: '3.450000'