QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505953#6429. Let's Play CurlingGrunrayWA 165ms12164kbC++202.9kb2024-08-05 14:03:312024-08-05 14:03:31

Judging History

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

  • [2024-08-05 14:03:31]
  • 评测
  • 测评结果:WA
  • 用时:165ms
  • 内存:12164kb
  • [2024-08-05 14:03:31]
  • 提交

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;
		sa.insert(x);
	}
	rep(i, 1, m) {
		cin >> x;
		sb.insert(x);
	}

	set<ll>::iterator it;
	int i = 1;
	for (it = sa.begin(); it != sa.end(); it++) {
		a[i++] = (*it);
	}
	n = i - 1;
	i = 1;
	for (it = sb.begin(); it != sb.end(); it++) {
		b[i++] = (*it);
	}
	m = i - 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';*/

	ll res = 0;

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

		res = max(res, r - l + 1);
	}
	//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;
}

詳細信息

Test #1:

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

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: 165ms
memory: 12164kb

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:

3
4
1
1
4
8
8
4
2
3
5
1
3
1
3
3
2
4
3
3
5
4
3
5
9
1
3
9
Impossible
2
1
1
4
1
2
2
4
4
3
6
10
4
4
Impossible
4
5
4
4
4
1
3
2
4
5
4
2
3
8
3
3
3
1
2
7
1
4
4
2
1
2
4
3
7
4
1
4
1
1
1
1
3
Impossible
8
1
1
Impossible
16
5
Impossible
4
4
4
3
4
3
1
3
2
3
3
2
2
5
3
7
1
1
2
4
Impossible
2
3
7
3
1
1
1
5
3
4
Impo...

result:

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