QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#36800 | #2442. Welcome Party | afhi | WA | 300ms | 5332kb | C++ | 2.3kb | 2022-06-28 20:41:57 | 2022-06-28 20:41:57 |
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);
auto gao = [&] () {
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;
for (int i = 0,j;i < n;i = j) {
j = i;
while (j < n && x[order[j]] == x[order[i]]) {
j++;
}
if (max_y != -1) {
for (int k = i;k < j;k++) {
ckmin(ans,std::abs(max_y - x[order[k]]));
}
}
for (int k = i;k < j;k++) {
ckmax(max_y,y[order[k]]);
}
}
int cnt = 0;
ll max_x = x[order[0]];
for (int i = 0;i < n;i++) {
if (x[order[i]] != max_x) break;
cnt++;
}
for (int i = 0;i < n;i++) {
if (cnt == 1 && i == 0) continue;
ckmin(ans,std::abs(y[order[i]] - max_x));
}
};
gao();
std::swap(x,y);
gao();
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 300ms
memory: 5332kb
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 146595730144168239 10974087366700578 21076180420813408 183538167814754058 46751451188711820 365292306661444331 23639646046527434 40476687889457528 270663364266559542 139940820548070767 21494649603533736 100200...
result:
wrong answer 57th lines differ - expected: '5560732879123793', found: '6425248386675430'