QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56898#2521. KeystrokeSa3tElSefr#AC ✓2ms3720kbC++966b2022-10-21 20:18:342022-10-21 20:18:36

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-21 20:18:36]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3720kb
  • [2022-10-21 20:18:34]
  • 提交

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;
}


詳細信息

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