wybl,我要崩了,一直70分,狂WA。。。
查看原帖
wybl,我要崩了,一直70分,狂WA。。。
658786
STUDENT00楼主2022/11/27 13:49

代码:

#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
struct node{
	int a,b;
	friend bool operator<(const node x,const node y){
		if(x.a!=y.a) return x.a<y.a;
		return x.b<y.b;
	}
} A[100010];
int n,m,k,ans=1;
int qpow(int a,int b){
	int s=1;
	while(b){
		if(b&1LL) s=s*a%mod;
		a=a*a%mod;
		b>>=1LL;
	}
	return s;
}
signed main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=k;i++) scanf("%lld%lld",&A[i].a,&A[i].b);
	sort(A+1,A+k+1);
	int s=(1+n)*n/2,now=1,ss=0;
	while(now<=k){
		set<int> st;
		int t=A[now].a,p=s;
		while(A[now].a==t) st.insert(A[now++].b);
		for(set<int>::iterator it=st.begin();it!=st.end();it++) p-=*it;
		ans=ans*p%mod;
		ss++;
	} 
	ans=ans*qpow(s,m-ss)%mod;
	printf("%lld",ans);
	return 0;
}
2022/11/27 13:49
加载中...