QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325349#7786. Graft and TransplantZhouShang#WA 0ms3728kbC++201.5kb2024-02-11 08:37:162024-02-11 08:37:16

Judging History

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

  • [2024-02-11 08:37:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3728kb
  • [2024-02-11 08:37:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
int main(){
	int T;
	cin>>T;
	while(T--){
		int A,B;
		int a[6],b[6];
		scanf("%d%d",&A,&B);
		for(int i=0;i<3;i++) scanf("%d%d",&a[i],&b[i]),a[i+3]=a[i],b[i+3]=b[i];
		int f=0;
		for(int i=0;i<3;i++)
			if(a[i]==A&&b[i]==B){
				f=1;
				long long ans=0;
				for(int j=0;j<3;j++)
					if(j!=i) ans+=1LL*(A-a[j]+1)*(B-b[j]+1)%mod;
				printf("%lld\n",ans%mod);
			}
		long long ans=0;
		for(int i=0;i<3;i++){
			int fr=a[i]==A||b[i+1]==B,fl=b[i]==B||a[i+1]==A;
			if(!fr&&!fl) continue;
			else if(fr+fl==1){
				assert(a[i]+a[i+1]>=A&&b[i]+b[i+1]>=B);
				int aa=fr?A-a[i+1]:A-a[i],bb=fr?B-b[i]:B-b[i+1];
				if(a[i+2]>=aa&&b[i+2]>=bb) ans++;
			}
			else{
				int aa,bb;
				if(a[i]==A){
					assert(a[i+1]==A);
					aa=A,bb=max(0,B-b[i]-b[i+1]);
				}
				else{
					assert(b[i+1]==B);
					bb=B,aa=max(0,A-a[i]-a[i+1]);
				}
				if(a[i+2]>=aa&&b[i+2]>=bb){
					long long val=1;
					if(aa==0) val=val*(A-a[i+2]+1)%mod;
					else val=val*(a[i+2]-aa+1)%mod;
					if(bb==0) val=val*(B-b[i+2]+1)%mod;
					else val=val*(b[i+2]-bb+1)%mod;
					ans=(ans+val)%mod;
				}
			}
			cout<<"#"<<i<<" "<<fl<<" "<<fr<<" "<<ans<<endl;
			ans%=mod;
		}
		cout<<ans<<endl;
	}
	return 0;
}
/*
5
2 2
1 1
1 1
1 1
0
2 2
1 1
1 2
1 2
#0 0 1 1
#1 1 1 1
#2 1 0 2
2
2 2
1 1
1 2
2 1
#0 0 1 1
#1 1 0 2
#2 0 1 3
3
2 2
1 2
1 2
1 2
#0 1 1 2
#1 1 1 4
#2 1 1 6
6
2 2
1 2
1 2
2 1
#0 1 1 0
#1 1 0 1
#2 0 1 2
2
*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3728kb

input:

4
1 2
2 3
3 4

output:

0
0
0
0

result:

wrong answer 1st words differ - expected: 'Alice', found: '0'