QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#505995#6429. Let's Play CurlingGrunrayWA 84ms5196kbC++203.1kb2024-08-05 14:29:552024-08-05 14:29:56

Judging History

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

  • [2024-08-05 14:29:56]
  • 评测
  • 测评结果:WA
  • 用时:84ms
  • 内存:5196kb
  • [2024-08-05 14:29:55]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#define itn int
#define PII pair<int, int>
#define PLI pair<long long, int>
#define fep(i, a, b) for(int i = (a); i >= (b); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#include<bits/stdc++.h>
#include<unordered_map>
using ll = long long;
using ldou = long double;
using unll = unsigned long long;
using namespace std;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (!isdigit(ch)) { f = ch != '-'; ch = getchar(); }
	while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
	return f ? x : -x;
}

ll gcd(ll a, ll b) { // 最大公约数
	while (b ^= a ^= b ^= a %= b)
		;
	return a;
}
ll lcm(ll a, ll b) { // 最小公倍数
	return a / gcd(a, b) * b;
}
ll qmi(ll m, ll k, ll p) { // 快速幂
	//求 m^k mod p,时间复杂度 O(logk)。
	//m为底数,k为幂
	ll res = 1 % p, t = m;
	while (k) {
		if (k & 1) res = res * t % p;
		t = t * t % p;
		k >>= 1;
	}
	return res;
}
unll qmi(unll m, unll k, unll p) { //龟速乘
	ll res = 0, t = m;
	while (k) {
		if (k & 1) res = (res + t) % p;
		k >>= 1;
		t = (t << 1) % p;
	}
	return res;
}

////////////////////////////////////////////////////////////////////////////////


const int N = 1e5 + 50;
const int M = 2e5 + 50;
const ll INF = 0x3f3f3f3f;
const ll MODE = ll(998244353);
const double Pi = 3.1415926;
const double eps = 1e-8;
const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1,-1 };
//priority_queue<int> p;//这是一个大根堆q
//priority_queue<int, vector<int>, greater<int> >q;//这是一个小根堆q
//priority_queue<ll, vector<ll>, greater<ll> >pq; // 小根

ll n, m;
string str;

ll a[N], b[N];
set<ll>sa;
set<ll>sb;

void solve() {
	
	cin >> n >> m;

	/*rep(i, 1, n) cin >> a[i];
	rep(j, 1, m) cin >> b[j];*/
	ll x;
	rep(i, 1, n) {
		//cin >> x;
		cin >> a[i];
		//sa.insert(x);
	}
	rep(i, 1, m) {
		//cin >> x;
		//sb.insert(x);
		cin >> b[i];
	}

	set<ll>::iterator it;
	int pos = 1;
	/*for (it = sa.begin(); it != sa.end(); it++) {
		a[pos++] = (*it);
	}
	n = pos - 1;*/
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	/*pos = 1;
	for (it = sb.begin(); it != sb.end(); it++) {
		b[pos++] = (*it);
	}
	m = pos;*/
	m = ll(unique(b + 1, b + m + 1) - b) - 1;
	/*cout << "  a   ";
	for (int i = 1; i <= n; i++)cout << a[i] << ' ';
	cout << '\n';
	cout << "  b   ";
	for (int i = 1; i <= m; i++)cout << b[i] << ' ';
	cout << '\n';*/

	b[0] = 0;
	b[++m] = INF;

	ll res = 0;
	ll l, r;
	ll mid;
	rep(i, 1, m) {
		l = ll(upper_bound(a + 1, a + n + 1, b[i - 1]) - a);
		r = ll(lower_bound(a + 1, a + n + 1, b[i]) - a) - 1;

		mid = r - l + 1;

		res = max(res, mid);
	}
	//cout << "******   ";
	if (!res) cout << "Impossible\n";
	else cout << res << '\n';

	/*sa.clear();
	sb.clear();*/
}

signed main() {
	std::ios::sync_with_stdio(false); std::cin.tie(0), std::cout.tie(0);
	/*freopen("out.txt", "r", stdin);
	freopen("wrt.txt", "w", stdout);*/
	int TTT = 1; cin >> TTT;
	while (TTT--) {
		solve();
	}
	/*while (cin >> n >> m) {
		solve();
	}*/

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 2
2 3
1 4
6 5
2 5 3 7 1 7
3 4 3 1 10
1 1
7
7

output:

2
3
Impossible

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 84ms
memory: 5196kb

input:

5553
12 19
8 8 11 18 12 9 15 38 6 32 30 30
17 28 33 2 37 20 11 38 36 18 18 30 20 33 13 31 33 37 8
12 6
7 12 14 2 19 2 17 7 4 20 1 13
7 18 23 22 1 16
8 7
5 2 4 2 4 5 8 12
13 16 6 6 5 16 11
5 7
5 13 3 8 3
11 6 9 11 13 8 11
17 19
944782509 244117333 140979583 661724696 617847780 321687699 418677763 725...

output:

9
3
4
3
8
8
11
4
2
4
11
5
4
3
15
3
9
4
6
13
6
4
5
4
12
2
6
9
3
3
1
4
6
11
4
3
4
5
4
6
9
4
5
13
3
5
4
5
5
1
6
10
4
5
5
5
6
8
3
4
10
2
4
5
4
5
6
10
2
5
5
4
6
5
1
7
1
3
2
4
4
12
17
2
2
3
19
5
5
4
3
4
5
4
4
3
8
5
13
2
3
6
9
6
19
2
1
2
4
7
7
10
7
12
1
2
2
4
6
10
1
3
4
4
13
2
1
13
4
8
14
6
2
13
6
3
6
5
6
...

result:

wrong answer 1st lines differ - expected: '1', found: '9'