結果
問題 |
No.2353 Guardian Dogs in Spring
|
ユーザー |
![]() |
提出日時 | 2023-06-16 21:55:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 760 bytes |
コンパイル時間 | 4,217 ms |
コンパイル使用メモリ | 258,000 KB |
最終ジャッジ日時 | 2025-02-14 05:25:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 3 TLE * 11 MLE * 5 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; int main(){ int n; cin >> n; vector<int> x(n), y(n); for (int i=0; i<n; i++){ cin >> x[i] >> y[i]; } cout << n/2 << endl; priority_queue<tuple<int,int,int>> pq; for (int i=0; i<n; i++){ for (int j=i+1; j<n; j++){ int dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); pq.push(tuple(-dist, i, j)); } } vector<bool> seen(n); int cnt = 0; while(!pq.empty()){ auto [r, i, j] = pq.top(); pq.pop(); if (seen[i] || seen[j]) continue; cout << i+1 << " " << j+1 << endl; seen[i] = true; seen[j] = true; cnt++; if (cnt == n / 2) break; } assert(cnt == n / 2); }