QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163603#7107. Chaleurucup-team1321AC ✓148ms8176kbC++231.7kb2023-09-04 12:12:012023-09-04 12:12:03

Judging History

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

  • [2023-09-04 12:12:03]
  • 评测
  • 测评结果:AC
  • 用时:148ms
  • 内存:8176kb
  • [2023-09-04 12:12:01]
  • 提交

answer

#include <bits/stdc++.h>

#ifndef LOCAL
#define debug(...) 42
#endif
#define rep(i, x, y) for (int i = x; i < y; i++)
#define rp(i, n) rep(i, 0, n)
#define pb emplace_back
using namespace std;
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
  x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
  x = x > y ? x : y;
}
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(time(NULL));
const int inf = 1000000000;
const ll lnf = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)

void solve() {
  int n, m;
  cin >> n >> m;
  vc<vi> adj(n);
  rp(i,m){
    int x,y;
    cin>>x>>y;
    --x,--y;
    adj[x].pb(y);
    adj[y].pb(x);
  }
  vi p(n);
  iota(all(p),0);
  sort(all(p),[&](auto x,auto y){
    return sz(adj[x])>sz(adj[y]);
  });
  vi vis(n);
  int cnt=0;
  for(auto x:p){
    int res=0;
    for(auto y:adj[x]){
      if(vis[y]){
        res+=1;
      }
    }
    if(res==cnt){
      cnt+=1;
      vis[x]=1;
    }
  }
  int ans1=1;
  int ans2=1;
  rp(i,n){
    if(!vis[i] && sz(adj[i])==cnt-1){
      ans1+=1;
    }
  }
  rp(i,n){
    if(vis[i] && sz(adj[i])==cnt-1){
      cnt--;
      vis[i]=0;
    }
  }
  rp(i,n){
    if(vis[i] && sz(adj[i])==cnt){
      ans2+=1;
    }
  }
  cout << ans1 << " " << ans2 << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 148ms
memory: 8176kb

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