QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#161355#7107. Chaleurucup-team139#AC ✓141ms16124kbC++231.5kb2023-09-02 23:29:382023-09-02 23:29:40

Judging History

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

  • [2023-09-02 23:29:40]
  • 评测
  • 测评结果:AC
  • 用时:141ms
  • 内存:16124kb
  • [2023-09-02 23:29:38]
  • 提交

answer

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

const int MAXN = 100'005;
int n,m;
vector<int> grafo[MAXN],tmp;
bool clique[MAXN];

bool comp(int x,int y){
    return grafo[x].size()>grafo[y].size();
}

void solve(int t){
    cin>>n>>m;
    
    tmp.clear();
    for(int i=1;i<=n;i++){
        grafo[i].clear();
        tmp.push_back(i);
        clique[i]=false;
    }
    
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        grafo[a].push_back(b);
        grafo[b].push_back(a);
    }
    sort(tmp.begin(),tmp.end(),comp);
    
    
    int ans1=1,last=0,siz=0;
    
    for(int i=0;i<n;i++){
        int nod=tmp[i];
        
        int cont=0;
        for(auto j : grafo[nod]){
            if(clique[j])cont++;
        }
        
        if(cont==siz){
            siz++;
            clique[nod]=true;
            last=i;
        }else if(cont==siz-1){
            ans1++;
        }
    }
    
    siz = n-siz;
    int ans2=1,mini=1;
    for(int i=0;i<=last;i++){
        int nod=tmp[i];
        
        int cont=0;
        for(auto j : grafo[nod]){
            if(!clique[j])cont++;
        }
        
        if(cont<mini){
            mini=cont;
            ans2=1;
        }else if(cont==mini){
            ans2++;
        }
    }
    
    cout<<ans1<<" "<<ans2<<"\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

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

output:

2 1
1 4
1 2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 141ms
memory: 16124kb

input:

2231
1 0
5 7
4 1
3 4
3 1
3 5
4 2
3 2
4 5
5 4
2 1
2 5
2 4
2 3
5 10
3 2
2 5
1 4
4 2
4 5
1 2
1 3
3 5
3 4
1 5
5 10
1 3
2 4
1 4
5 2
2 3
1 5
5 4
1 2
3 4
5 3
5 9
2 5
3 5
2 3
2 1
4 3
3 1
4 1
4 5
2 4
5 4
4 2
4 1
4 5
4 3
5 9
4 1
4 5
3 4
2 4
2 1
3 1
2 5
3 5
3 2
5 4
2 5
2 3
2 1
2 4
5 9
5 2
1 3
4 3
1 2
5 4
4 2
5...

output:

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

result:

ok 2231 lines

Extra Test:

score: 0
Extra Test Passed