QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707315#2521. KeystrokebecaidoAC ✓0ms3620kbC++201.4kb2024-11-03 15:28:142024-11-03 15:28:17

Judging History

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

  • [2024-11-03 15:28:17]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-03 15:28:14]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout<<"["<<#HEHE<<"] : ",dout(HEHE)
void dout(){cout<<'\n';}
template<typename T,typename...U>
void dout(T t,U...u){cout<<t<<(sizeof...(u)?", ":""),dout(u...);}
#else
#define debug(...) 7122
#endif

#define int long long
#define ll long long
#define Waimai ios::sync_with_stdio(false),cin.tie(0)
#define FOR(x,a,b) for(int x=a,I=b;x<=I;x++)
#define pb emplace_back
#define F first
#define S second

void solve() {
    int n, m;
    cin >> n >> m;
    int a[n], b[m];
    FOR (i, 0, n - 1) cin >> a[i];
    FOR (i, 0, m - 1) cin >> b[i];
    int ans = 0;
    FOR (i, 1, (1 << 4) - 1) {
        bool ix[2] = {}, iy[2] = {};
        FOR (j, 0, 3) if (i >> j & 1) {
            ix[j / 2] = 1;
            iy[j % 2] = 1;
        }
        bool f = 1;
        if (ix[0] && ix[1]) f &= n == 2;
        else if (ix[0]) f &= n == 1 && a[0] == 0;
        else if (ix[1]) f &= n == 1 && a[0] == 1;
        else f = 0;
        if (iy[0] && iy[1]) f &= m == 2;
        else if (iy[0]) f &= m == 1 && b[0] == 0;
        else if (iy[1]) f &= m == 1 && b[0] == 1;
        else f = 0;
        ans += f;
    }
    cout << ans << '\n';
}

int32_t main() {
    Waimai;
    int tt = 1;
    cin >> tt;
    while (tt--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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