QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#36786#2442. Welcome Partyyyf_0404WA 614ms11572kbC++1.3kb2022-06-28 20:01:352022-06-28 20:01: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-06-28 20:01:36]
  • 评测
  • 测评结果:WA
  • 用时:614ms
  • 内存:11572kb
  • [2022-06-28 20:01:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
struct Pr
{
    long long x, y;
    bool operator < (const Pr& b)const
    {
        return y > b.y;
    }
}a[100005];
struct Unit
{
    long long x;
    int id;
    Unit(long long x = 0, int id = 0): x(x), id(id){}
    bool operator < (const Unit& b)const
    {
        return x < b.x || x == b.x && id < b.id;
    }
};
set<Unit> q;
void solve()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d%d", &a[i].x, &a[i].y);
    sort(a, a + n);
    for(int i = 0; i < n; i++)
        q.insert(Unit(a[i].x, i));
    long long maxn = -1, minn = 0x7fffffffffffffff;
    for(int i = 0; i < n; i++){
        q.erase(Unit(a[i].x, i));
        if(i == n - 1){
            minn = min(minn, abs(maxn - a[i].y));
            continue;
        }
        auto p1 = q.lower_bound(Unit(a[i].y, -1));
        if(p1 != q.end() && p1->x > maxn)
            minn = min(minn, p1->x - a[i].y);
        if(p1 != q.begin()){
            p1--;
            if(p1->x > maxn)
                minn = min(minn,  a[i].y - p1->x);
        }
        if(i) minn = min(minn, abs(maxn - a[i].y));
        maxn = max(maxn, a[i].x);
    }
    printf("%lld\n", minn);
}
int main()
{
    int T;
    scanf("%d", &T);
    while(T--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 614ms
memory: 11572kb

input:

66
5
27 46
89 13
55 8
71 86
22 35
3
3 5
4 7
6 2
2
0 1000000000
1000000000 0
2
1000000000 0
0 1000000000
2
1000000000 0
1000000000 0
2
0 1000000000
0 1000000000
2
1000000000 1000000000
0 0
2
0 0
0 0
2
1000000000 1000000000
1000000000 1000000000
3
90 30
90 50
90 85
3
0 0
0 2
0 5
3
20 30
20 50
20 70
3
...

output:

3
1
0
0
1000000000
1000000000
1000000000
0
0
5
0
10
5
10
3
0
10
5
0
5
0
10
5
10
3
0
10
5
0
14195379
6981410
45629128
1037663623
2027311500
507704597
6174589
955963135
370094097
1121730960
439397288
462308063
848943178
133505742
42553324
484288608
135053668
331371108
102551432
386248676
3327787489
84...

result:

wrong answer 30th lines differ - expected: '146595730144168239', found: '14195379'