QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#161048#7107. Chaleurucup-team197#AC ✓199ms65856kbC++141.1kb2023-09-02 22:16:032023-09-02 22:16:03

Judging History

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

  • [2023-09-02 22:16:03]
  • 评测
  • 测评结果:AC
  • 用时:199ms
  • 内存:65856kb
  • [2023-09-02 22:16:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=998244353;
const int N=2e6+1;
typedef pair<ll,int> pli;
int n,m;
vector<int>adj[N];
pair<int,int>d[N];
int pos[N];
void solve(){
	cin >> n >> m;
	int w1=1,w2=1;
	for(int i=1; i<=n ;i++) adj[i].clear();
	for(int i=1; i<=m ;i++){
		int u,v;cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i=1; i<=n ;i++){
		d[i]={adj[i].size(),i};
	}
	sort(d+1,d+n+1);
	for(int i=1; i<=n ;i++) pos[d[i].se]=i;
	{
		int p=0;
		for(int i=n; i>=1 ;i--){
			int cnt=0;
			for(auto c:adj[d[i].se]) cnt+=(pos[c]>i);
			if(cnt==p) p++;
			else break;
		}
		for(int i=1; i<=n-p ;i++){
			if(d[i].fi==p-1) w1++;
		}
		
	}
	{
		int p=0;
		for(int i=1; i<=n ;i++){
			int cnt=0;
			for(auto c:adj[d[i].se]) cnt+=(pos[c]<i);
			if(cnt==0) p++;
			else break;
		}
		//cout << "haha " << p << endl;
		for(int i=p+1; i<=n ;i++){
			if(n-d[i].fi-1==p-1) w2++;
		}
		
	}
	cout << w1 << ' ' << w2 << '\n';
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	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: 3ms
memory: 53340kb

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: 199ms
memory: 65856kb

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