QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216182#7581. Radar ScannerSolitaryDream#AC ✓249ms22348kbC++171.2kb2023-10-15 16:31:532023-10-15 16:31:54

Judging History

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

  • [2023-10-15 16:31:54]
  • 评测
  • 测评结果:AC
  • 用时:249ms
  • 内存:22348kb
  • [2023-10-15 16:31:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
typedef long long ll;
const int N=1005;
const int M=1e5+50;
int f[N][N][4];
ll C[M][4];
void add(int x1,int x2,int y1,int y2,int p) {
    f[x1][y1][p]++;
    f[x2+1][y1][p]--;
    f[x1][y2+1][p]--;
    f[x2+1][y2+1][p]++;
}
void solve() {
    memset(f,0,sizeof(f));
    int n;
    cin >> n;
    FOR(i,0,n) {
        C[i][0]=1;
        FOR(j,1,min(i,3)) C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
    while(n--) {
        int x1,x2,y1,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        add(x1,x1,y1,y1,0);
        add(x1,x1,y1+1,y2,1);
        add(x1+1,x2,y1,y1,2);
        add(x1+1,x2,y1+1,y2,3);
    }
    ll res=0;
    FOR(i,1,1000) FOR(j,1,1000) {
        FOR(k,0,3) f[i][j][k]+=f[i-1][j][k]+f[i][j-1][k]-f[i-1][j-1][k];
        // if(i==2 && j==2) cerr << f[2][2][0] << endl;
        FOR(v0,0,3) FOR(v1,0,3-v0) FOR(v2,0,3-v0-v1) {
            if(v0+v1 && v0+v2) res+=C[f[i][j][0]][v0]*C[f[i][j][1]][v1]*C[f[i][j][2]][v2]*C[f[i][j][3]][3-v0-v1-v2];
        }
    }
    cout << res << '\n';
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 24ms
memory: 20092kb

input:

2
3
3 1 3 1
1 1 2 3
2 1 3 2
5
1 1 4 5
2 1 3 2
2 2 3 3
4 5 4 5
1 2 2 4

output:

0
4

result:

ok 2 number(s): "0 4"

Test #2:

score: 0
Accepted
time: 249ms
memory: 22348kb

input:

10
5
2 1 3 3
1 5 1 5
1 2 2 3
4 1 5 3
1 2 4 4
10
3 3 7 5
3 4 3 4
5 4 6 6
8 1 10 6
6 1 9 8
2 6 8 10
3 2 8 7
5 1 5 8
2 2 7 7
1 1 2 3
100
1 37 28 37
1 5 6 40
9 29 47 30
12 9 12 9
40 14 45 14
13 28 16 34
44 8 46 47
23 9 40 42
13 1 35 17
9 31 46 31
1 10 34 48
5 35 46 50
16 21 28 49
3 6 3 24
5 3 39 28
30 8...

output:

1
31
16256
29932636832595
20948001862043
20395156087285
20094030388871
20143137954387
19922797032244
20114049116806

result:

ok 10 numbers