QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#57774#2521. KeystrokeAs3b_team_f_masr#AC ✓2ms3640kbC++1.6kb2022-10-22 21:14:552022-10-22 21:14:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-22 21:14:56]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3640kb
  • [2022-10-22 21:14:55]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define EPS 1e-9
#define PI acos(-1.0)
#define ll long long
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define pb push_back
#define ft first
#define sc second
#define pi pair<ll,ll>
#define vi vector<ll>
#define sz(s) s.size()
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll N = 2e5+5, M = 250, MOD = (1LL<<32), INF = 1e18;
int dx[] = {-1, 1, 0, 0}, Dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};;
int dy[] = {0, 0, 1, -1}, Dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll n, m, t, a[N];
map<pair<set<int>,set<int>>,int> ans;

void solve(int cnt,set<int>r,set<int>c)
{
    if(cnt == 5){
        ans[{r,c}]++;
        return;
    }
    set<int> R = r, C = c;
    solve(cnt+1,R,C);
    R.insert((cnt-1)/2);
    C.insert((cnt-1)%2);
    solve(cnt+1,R,C);
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);//freopen("lines.in", "r", stdin);
    solve(0,{},{});
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        set<int> r,c;
        for(int i = 0,rr; i < n ;++i) {
            cin >> rr;
            r.insert(rr);
        }
        for(int i = 0,rr; i < m ;++i) {
            cin >> rr;
            c.insert(rr);
        }
        cout << ans[{r,c}] << '\n';
    }

    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 2ms
memory: 3588kb

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: 2ms
memory: 3640kb

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