QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528153#2521. KeystrokeNYCU_CartesianTree#AC ✓0ms3668kbC++14875b2024-08-23 10:38:412024-08-23 10:38:42

Judging History

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

  • [2024-08-23 10:38:42]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3668kb
  • [2024-08-23 10:38:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int cnt[1 << 2][1 << 2];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 0; i < (1 << 4); i++){
        int typex = 0, typey = 0;
        for(int j = 0; j < 4; j++){
            if(i & (1 << j)){
                int x = j / 2;
                int y = j % 2;
                typex |= (1 << x);
                typey |= (1 << y);
            }
        }
        cnt[typex][typey]++;
    }
    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        int typex = 0, typey = 0;
        int in;
        for(int i = 0; i < n; i++){
            cin >> in;
            typex |= (1 << in);
        }
        for(int i = 0; i < m; i++){
            cin >> in;
            typey |= (1 << in);
        }
        cout << cnt[typex][typey] <<'\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

2
2 1
0 1
0
1 2
1
0 1

output:

1
1

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

2
2 2
0 1
0 1
1 1
1
1

output:

7
1

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

9
1 1
0
0
1 1
0
1
1 1
1
0
1 1
1
1
1 2
0
0 1
1 2
1
0 1
2 1
0 1
0
2 1
0 1
1
2 2
0 1
0 1

output:

1
1
1
1
1
1
1
1
7

result:

ok 9 lines