QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619186#2442. Welcome PartyIllusionaryDominance#WA 324ms13200kbC++201.1kb2024-10-07 13:27:092024-10-07 13:27:11

Judging History

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

  • [2024-10-07 13:27:11]
  • 评测
  • 测评结果:WA
  • 用时:324ms
  • 内存:13200kb
  • [2024-10-07 13:27:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
struct people{
    long long x, y;
}a[N];
bool pd(people p1, people p2){return p1.x < p2.x;}
long long suf[N];
int n;
long long ans = 1e18;
set<long long>se;

void upd(long long X, long long Y){
    if(se.lower_bound(X) != se.end())
         ans = min(ans, abs(max(*se.lower_bound(X), Y) - X));
    if(se.lower_bound(X) != se.begin())
        ans = min(ans, abs(max(*(--se.lower_bound(X)), Y) - X));
    
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int T; cin >> T;
    while(T --){
        for (int i = 1; i <= n; ++ i) suf[i] = 0;
        cin >> n;
        for (int i = 1; i <= n; ++ i) cin >> a[i].x >> a[i].y;
        sort(a + 1, a + 1 + n, pd);
        for (int i = n; i; -- i) suf[i] = max(suf[i + 1], a[i].y);
        ans = 1e18;
        se.clear();
        a[0].x = -1;
        for (int i = 1; i <= n; ++ i){
            if(a[i].x != a[i - 1].x) upd(a[i].x, suf[i + 1]); 
            se.insert(a[i].y);
            if(a[i].x == a[i - 1].x) upd(a[i].x, suf[i + 1]); 
        }
        cout << ans << "\n";
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 324ms
memory: 13200kb

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
2
30
10
10
3
0
10
5
0
146595730144168239
13421384895232913
21076180420813408
183538167814754058
46751451188711820
365292306661444331
23639646046527434
40476687889457528
288226349800603942
139940820548070767
48500389324554138
41398...

result:

wrong answer 21st lines differ - expected: '0', found: '2'