QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478285#7520. Monster GeneratorasitshouldbeWA 2ms13856kbC++142.5kb2024-07-14 20:01:382024-07-14 20:01:39

Judging History

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

  • [2024-07-14 20:01:39]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:13856kb
  • [2024-07-14 20:01:38]
  • 提交

answer

#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#define x first
#define y second
#define endl '\n'
#define pi acos(-1.0)
using namespace std;
typedef pair<int, int> PII;
typedef pair<double, int> PDI;
typedef pair<PII, int> PIII;
typedef pair<PII, char> PIIC;
typedef long long LL;
int dx[] = {1, 0, 0, -1, -1, -1, 1, 1}, dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
int mou[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int N = 1e6 + 10, M = 110, mod = 998244353, INF = 0x3f3f3f3f;
const double eps = 1e-8;
int n,m,t,ne[N],e[N],h[N],d[N],dis[N],ans[N],idx;

void add(int a,int b)
{
    e[idx]=b;
    ne[idx]=h[a];
    h[a]=idx++;
}

void bfs(int s)
{
    //for(int i=1;i<=n;i++) dis[i]=-1;
    set<int>sc,ts;
    queue<int>q;
    for(int i=1;i<=n;i++) sc.insert(i);
    sc.erase(s);
    q.push(s);
    dis[s]=0;
    while(q.size())
    {
        auto ver=q.front();
        q.pop();
        for(int i=h[ver];i!=-1;i=ne[i])
        {
            int j=e[i];
            //if(dis[j]==-1)
            if(sc.count(j))
            {
                sc.erase(j);
                ts.insert(j);
            }
        }
        //cout<<ver<<endl;
        for(auto it:sc)
        {
            dis[it]=dis[ver]+1;
            if(it>s||2*d[it]<n)
            {
                //cout<<s<<" "<<it<<" "<<dis[it]<<" "<<ver<<" "<<dis[ver]<<endl;
                ans[dis[it]]++;
            }
            q.push(it);
        }
        sc=ts;
        ts.clear();
    }
}

void solve()
{
    memset(h,-1,sizeof h);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        d[a]++,d[b]++;
        add(a,b),add(b,a);
    }
    LL cnt1=0,cnt2=0;
    for(int i=1;i<=n;i++)
        if(2*d[i]>=n) bfs(i);
        else
        {
            cnt1++;
            for(int j=h[i];j!=-1;j=ne[j])
            {
                int k=e[j];
                if(k>i&&2*d[k]<n) cnt2++;
            }
        }
    ans[1]+=(cnt1-1)*cnt1/2-cnt2;
    ans[2]+=cnt2;
    for(int i=1;i<n;i++) cout<<ans[i]<<" ";

}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0),cout.precision(10);
    // freopen("in.in","r",stdin);
    // freopen("test.out","w",stdout);  
    t=1; // cin >> t;
    while (t--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 13856kb

input:

3 5
3 1 5 2
4 2 1 3
1 9 100 1

output:

2 1 

result:

wrong answer 1st lines differ - expected: '113', found: '2 1 '