結果
| 問題 |
No.2353 Guardian Dogs in Spring
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-13 23:11:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,305 bytes |
| コンパイル時間 | 2,136 ms |
| コンパイル使用メモリ | 216,500 KB |
| 最終ジャッジ日時 | 2025-02-13 00:13:12 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793238462643383279;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
map<ll, vector<ll>> X;
map<pll, ll> index;
ll N;
cin >> N;
for (ll i = 0; i < N; ++i) {
ll x, y;
cin >> x >> y;
index[{x, y}] = i;
X[x].push_back(y);
}
pll before = {-1, -1};
vector<pll> ans;
for (const auto& [key, temp] : X){
vector<ll> value = temp;
sort(rng(value));
for (ll i = 0; i < (ll)value.size(); ++i) {
ll index1 = index[{key, value.at(i)}];
if (before.first != -1) {
ans.push_back({index[before] + 1, index1 + 1});
before = {-1, -1};
}
else {
before = {key, value.at(i)};
}
}
}
cout << ans.size() << "\n";
for (ll i = 0; i < ans.size(); ++i) {
cout << ans.at(i).first << ' ' << ans.at(i).second << "\n";
}
}