QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#505964 | #6429. Let's Play Curling | Ink_bai | WA | 0ms | 3708kb | C++20 | 2.2kb | 2024-08-05 14:14:26 | 2024-08-05 14:14:28 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
inline int fastInput() {
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int main()
{
int T;
T = fastInput();
while(T--)
{
int n, m;
int aa = 0, bb = 0;
n = fastInput();
m = fastInput();
vector<pair<int, int>> v;
for(int i = 0; i < n; i++)
{
int x;
x = fastInput();
v.push_back({x, 0});
aa++;
}
for(int i = 0; i < m; i++)
{
int x;
x = fastInput();
v.push_back({x, 1});
bb++;
}
sort(v.begin(), v.end());
for(int i = 1; i < v.size(); i++)
{
if(v[i].second == 1)
{
int t = v[i].first;
for(int j = i - 1; j >= 0; j--)
{
if(v[j].first == t && v[j].second == 0)
{
v.erase(v.begin() + j);
aa--;
}
else
{
break;
}
}
}
if(v[i].second == 1 && v[i - 1].second == 1)
{
v.erase(v.begin() + i - 1);
}
}
for(auto i : v)
{
cout << i.first << " " << i.second << endl;
}
if(aa <= 0)
{
printf("Impossible\n");
continue;
}
int l = 0, r = 0;
int maxn = 0;
for(int i = 0; i < v.size(); i++)
{
if(v[i].second == 1 || i == v.size() - 1)
{
r = i;
maxn = max(maxn, r - l);
l = i;
}
}
printf("%d\n", maxn - 1);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3708kb
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:
1 1 2 0 3 0 4 1 2 1 1 2 0 3 1 4 1 5 0 7 0 7 0 10 1 3 Impossible
result:
wrong answer 1st lines differ - expected: '2', found: '1 1'