QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505964#6429. Let's Play CurlingInk_baiWA 0ms3708kbC++202.2kb2024-08-05 14:14:262024-08-05 14:14:28

Judging History

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

  • [2024-08-05 14:14:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-08-05 14:14:26]
  • 提交

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

详细

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'