QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#36803 | #2442. Welcome Party | afhi | WA | 739ms | 10324kb | C++ | 2.4kb | 2022-06-28 20:52:29 | 2022-06-28 20:52:29 |
Judging History
answer
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <complex>
#include <list>
#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <random>
#ifdef AFHI
#include "debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ["; _print(##__VA_ARGS__)
#else
#define debug(...)
#endif
#define SZ(x) (int) x.size()
using ll = long long;
template<typename T> using V = std::vector<T>;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
void solve() {
int n;
std::cin>>n;
V<ll> x(n),y(n);
for (int i = 0;i < n;i++) {
std::cin>>x[i]>>y[i];
}
ll ans = ll(2e18);
V<int> order(n);
std::iota(order.begin(),order.end(),0);
std::sort(order.begin(),order.end(),[&] (int i,int j) {
return x[i] > x[j];
});
ll max_y = -1;
std::multiset<ll> ys(y.begin(),y.end());
for (int i = 0,j;i < n;i = j) {
j = i;
while (j < n && x[order[j]] == x[order[i]]) {
j++;
}
for (int k = i;k < j;k++) {
ckmin(ans,std::abs(max_y - x[order[k]]));
ys.erase(ys.find(y[order[k]]));
if (max_y < x[order[k]]) {
auto it = ys.lower_bound(x[order[k]]);
if (it != ys.end()) {
debug(*it,x[order[k]]);
ckmin(ans,std::abs(*it - x[order[k]]));
}
if (it != ys.begin()) {
it --;
if (*it > max_y) {
ckmin(ans,std::abs(*it - x[order[k]]));
}
}
}
ys.insert(y[order[k]]);
}
for (int k = i;k < j;k++) {
ys.erase(ys.find(y[order[k]]));
}
}
std::cout<<ans<<'\n';
}
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout<<std::fixed<<std::setprecision(10);
int t;
std::cin>>t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 739ms
memory: 10324kb
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 1 1 0 0 5 0 10 5 10 3 0 10 5 0 5 1 30 10 10 3 0 10 5 0 103423049738487445 13421384895232913 21076180420813408 183538167814754058 46751451188711820 58292659298928172 23639646046527434 4640409712116377 273836273245884003 139940820548070767 48500389324554138 351998083124311814 268073...
result:
wrong answer 6th lines differ - expected: '1000000000', found: '1'