QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56898 | #2521. Keystroke | Sa3tElSefr# | AC ✓ | 2ms | 3720kb | C++ | 966b | 2022-10-21 20:18:34 | 2022-10-21 20:18:36 |
Judging History
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 5;
int t, n, m;
int x[] = {0, 0, 0, 1, 1};
int y[] = {0, 0, 1, 0, 1};
map<pair<set<int>, set<int>>, int> mp;
void solve(int cur, set<int> r, set<int> c) {
if(cur == 5) {
mp[{r, c}]++;
return;
}
auto nr = r, nc = c;
solve(cur + 1, nr, nc);
nr.insert(x[cur]), nc.insert(y[cur]);
solve(cur + 1, nr, nc);
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
solve(1, {}, {});
cin >> t;
while(t--) {
cin >> n >> m;
set<int> r, c;
for(int i = 0;i < n;i++) {
int x;
cin >> x;
r.insert(x);
}
for(int i = 0;i < m;i++) {
int x;
cin >> x;
c.insert(x);
}
cout << mp[{r, c}] << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
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: 2ms
memory: 3720kb
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: 3552kb
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