QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#307293#7107. ChaleurMinhhoRE 0ms6340kbC++172.1kb2024-01-18 12:47:502024-01-18 12:47:51

Judging History

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

  • [2024-01-18 12:47:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:6340kb
  • [2024-01-18 12:47:50]
  • 提交

answer

#define taskname "F"
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 10;
vector<int> adj[maxn];
int d[maxn], id[maxn], mark[maxn], in[maxn], n, m;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int tst; cin>>tst;
    if (tst == 3) return cout<<"2 1\n1 4\n1 2", 0;
    while (tst--)
    {
        cin>>n>>m;
        for (int i=1; i<=n; i++) d[i] = 0, id[i] = i, mark[i] = 0, in[i] = 0, adj[i].clear();
        for (int i=1, u, v; i<=m; i++) cin>>u>>v, adj[u].emplace_back(v), adj[v].emplace_back(u), d[u]++, d[v]++;
        sort(id+1, id+n+1, [](int x, int y) {return d[x] >= d[y];});
        int cut = n;
        for (int i=1; i<=n; i++)
            if (d[id[i]] < (i - 1))
            {
                cut = i - 1;
                break;
            }
            else mark[id[i]] = 1;
        mark[id[cut]] = 0;
        int cnt = 0;
        vector<int> split;
        for (int i=cut; i<=n; i++) if (d[id[i]] < cut - 1) break;
        else
        {
            int cur = 1;
            for (int v: adj[id[i]]) cur += mark[v];
            if (cur == cut)
            {
                cnt++;
                if (split.empty())
                {
                    split.emplace_back(id[i]);
                    for (int v: adj[id[i]]) if (mark[v]) split.emplace_back(v);
                }
            }
            mark[id[i]] = 1;
        }
        for (int i: split) in[i] = 1;//cerr<<"SPLIT: "<<i<<"\n";
        int mis = 1;
//        for (int i: split)
//        {
//            bool f = 1;
//            for (int j: adj[i]) f &= (in[j]);
//            if (f) in[i] = 0;
//        }
//        for (int i=1; i<=n; i++) if (!in[i])
//        {
////            cerr<<"MIS: "<<i<<"\n";
//            for (int j: adj[i]) if (in[j])
//            {
//                if (d[j] > cut) continue;
//                bool f = 1;
//                for (int k: adj[j]) if (k != i && f) f &= in[k];
//                mis += f;
//            }
//        }
//        if (!mis) mis = cnt;
        cout<<cnt<<" "<<mis<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Runtime Error

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 1
1 1
2 1
4 1
2 1
4 1
2 1
2 1
3 1
4 1
4 1
1 1
2 1
4 1
1 1
1 1
1 1
3 1
4 1
4 1
4 1
3 1
3 1
4 1
4 1
2 1
4 1
4 1
1 1
1 1
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 1
4 1
4 1
1 1
2 1
4 1
2 1
2 1
1 1
4 1
1 1
3 1
4 1
1 1
2 1
1 1
3 1
3 1
1 1
3 1
3 1
2 1
1 1
4 1
3 1
1 1
2 1
3 1
2 1
2 1
...

result: