QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702437 | #7785. Three Rectangles | qiuuu# | Compile Error | / | / | C++23 | 3.7kb | 2024-11-02 15:59:13 | 2024-11-02 15:59:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OPFI(x) freopen(#x".in", "r", stdin);\
freopen(#x".out", "w", stdout)
#define REP(i, a, b) for(int i=(a); i<=(b); ++i)
#define REPd(i, a, b) for(int i=(a); i>=(b); --i)
inline ll rd(){
ll r=0, k=1; char c; while(!isdigit(c=getchar())) if(c=='-') k=-k;
while(isdigit(c)) r=r*10+c-'0', c=getchar(); return r*k;
}
constexpr int MOD=1e9+7;
ll t, H, W, h[10], w[10];
int main(){
OPFI(test1);
t=rd();
while(t--){
H=rd(), W=rd();
int tmp=0, flag=0, hhf=0, wwf=0;
REP(i, 1, 3){
h[i]=rd(), w[i]=rd();
if(h[i]==H||w[i]==W) ++tmp;
if(h[i]==H) ++hhf;
if(w[i]==W) ++wwf;
if(h[i]==H&&w[i]==W) flag=1;
}
if(flag){
ll ans=1;
REP(i, 1, 3) ans=ans*(H-h[i]+1)%MOD*(W-w[i]+1)%MOD;
printf("%lld\n", ans);
continue;
}
if(tmp==0){
puts("0");
}else if(tmp==1){
if(wwf){
swap(H, W);
swap(h[1], w[1]);
swap(h[2], w[2]);
swap(h[3], w[3]);
}
ll sumh=h[1]+h[2]+h[3]-H;
ll mnw=W, anw=0;
REP(i, 1, 3) if(h[i]!=H) mnw=min(mnw, w[i]); else anw=w[i];
if(mnw+anw>=W&&sumh>=H) puts("4");
else puts("0");
}else if(tmp==2){
if(wwf==2||hhf==2){
if(wwf){
swap(H, W);
swap(h[1], w[1]);
swap(h[2], w[2]);
swap(h[3], w[3]);
}
ll sumw=0, anh=0, anw=0;
REP(i, 1, 3) if(h[i]==H) sumw+=w[i]; else anh=h[i], anw=w[i];
if(sumw>=W){
printf("%lld\n", 2*(H-anh+1)%MOD*(W-anw+1)%MOD);
}else puts("0");
}else{
ll sumh=h[1]+h[2]+h[3]-H;
ll sumw=w[1]+w[2]+w[3]-W;
if(sumh>=H&&sumw>=W) puts("4");
else puts("0");
}
}else if(tmp==3){
if(wwf==3||hhf==3){
if(wwf){
swap(H, W);
swap(h[1], w[1]);
swap(h[2], w[2]);
swap(h[3], w[3]);
}
ll s=w[1]+w[2]+w[3];
if(s>=W){
ll ans=0;
REP(i, 1, 3){
if(s-w[i]>=W){
ans=(ans+2*(W-w[i]-1)+2)%MOD;
continue;
}
ll x=w[1], y=w[3];
if(i==1) x=w[2];
if(i==3) y=w[2];
ll top=max(1LL, W-y-w[i]), but=min(W-w[i]-1, x);
// cerr<<t<<": "<<top<<" "<<but<<endl;
ans=(ans+2*(but-top+1))%MOD;
if(w[i]+y>=W) ans=(ans+1)%MOD;
if(x+w[i]>=W) ans=(ans+1)%MOD;
}
printf("%lld\n", ans%MOD);
}else puts("0");
}else{
if(wwf==2){
swap(H, W);
swap(h[1], w[1]);
swap(h[2], w[2]);
swap(h[3], w[3]);
}
ll sumw=0, anh=0, anw=0;
REP(i, 1, 3) if(h[i]==H) sumw+=w[i]; else anh=h[i], anw=w[i];
if(sumw>=W){
printf("%lld\n", 2*(H-anh+1)%MOD*(W-anw+1)%MOD);
}else puts("0");
}
}
}
return 0;
}h
詳細信息
answer.code:109:2: error: ‘h’ does not name a type 109 | }h | ^ answer.code: In function ‘int main()’: answer.code:4:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 4 | #define OPFI(x) freopen(#x".in", "r", stdin);\ | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ answer.code:15:5: note: in expansion of macro ‘OPFI’ 15 | OPFI(test1); | ^~~~ answer.code:5:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | freopen(#x".out", "w", stdout) | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ answer.code:15:5: note: in expansion of macro ‘OPFI’ 15 | OPFI(test1); | ^~~~