QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#273782#7107. Chaleurikaurov#AC ✓434ms7612kbC++201.3kb2023-12-03 04:03:352023-12-03 04:03:36

Judging History

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

  • [2023-12-03 04:03:36]
  • 评测
  • 测评结果:AC
  • 用时:434ms
  • 内存:7612kb
  • [2023-12-03 04:03:35]
  • 提交

answer

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(arr) (arr).begin(), (arr).end()
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define endl '\n'

void solve(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> edges;
  vector<int> order(n), deg(n + 1);
  while (m--){
    int x, y;
    cin >> x >> y;
    edges.pb({x, y});
    edges.pb({y, x});
    deg[x]++, deg[y]++;
  }
  sort(all(edges));
  iota(all(order), 1);
  sort(all(order), [&] (int i, int j){
    return deg[i] > deg[j];
  });
  int sz = 0;
  while (sz < n){
    int v = order[sz];
    bool good = 1;
    for (int i = 0; i < sz; i++) good &= binary_search(all(edges), pair{order[i], v});
    if (!good) break;
    sz++;
  }
  int x = 1, y = 0;
  for (int i = 0; i < n; i++){
    int v = order[i];
    if (i < sz) y += (deg[v] == sz - 1);
    else x += (deg[v] == sz - 1);
  }
  if (!y){
    y = 1;
    for (int i = 0; i < sz; i++){
      int v = order[i];
      y += (deg[v] == sz);
    }
  }

  cout << x << " " << y << endl;
}

signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // cout.precision(20);
  int t;
  cin >> t;
  while (t--){
    solve();
  }
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

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: 434ms
memory: 7612kb

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