QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762003#2521. KeystrokeSanguineChameleon#AC ✓1ms3704kbC++201.0kb2024-11-19 12:21:492024-11-19 12:21:49

Judging History

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

  • [2024-11-19 12:21:49]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3704kb
  • [2024-11-19 12:21:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void justDoIt();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    justDoIt();
    return 0;
}

void test() {
    int n, m;
    cin >> n >> m;
    int row = 0;
    int col = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        row |= (1 << x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        col |= (1 << x);
    }
    int res = 0;
    for (int mask = 0; mask < 16; mask++) {
        int row2 = 0;
        int col2 = 0;
        for (int i = 0; i < 4; i++) {
            if ((mask >> i) & 1) {
                int r = (i >> 1);
                int c = (i & 1);
                row2 |= (1 << r);
                col2 |= (1 << c);
            }
        }
        if (row == row2 && col == col2) {
            res++;
        }
    }
    cout << res << '\n';
}

void justDoIt() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        test();
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

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: 3704kb

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: 3588kb

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