Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
using namespace std; typedef long long ll; const int maxn = 3e5 + 10; const ll INF = 3e16 + 10; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector
> cords(n); for(int i = 0; i < n; i++) { cin >> cords[i].first >> cords[i].second; } sort(cords.begin(), cords.end()); set
> st; st.insert(make_pair(cords[0].first, cords[0].second)); ll shortest_distance = 1e9, result = 1e9; for(int i = 1; i < n; i++) { set
>::iterator it1 = st.lower_bound(make_pair(cords[i].first - shortest_distance, cords[i].second - shortest_distance)); set
>::iterator it2 = st.upper_bound(make_pair(cords[i].first + shortest_distance, cords[i].second + shortest_distance)); if(it1 == st.end()) { continue; } for(set
>::iterator it = it1; it != it2; it++) { ll dist = (cords[i].first - it->first) * (cords[i].first - it->first) + (cords[i].second - it->second) * (cords[i].second - it->second); result = min(result, dist); shortest_distance = min(shortest_distance, dist); } st.insert(make_pair(cords[i].first, cords[i].second)); } cout << sqrt(result) << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)