QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#57774 | #2521. Keystroke | As3b_team_f_masr# | AC ✓ | 2ms | 3640kb | C++ | 1.6kb | 2022-10-22 21:14:55 | 2022-10-22 21:14:56 |
Judging History
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