結果

問題 No.2353 Guardian Dogs in Spring
ユーザー t98slider
提出日時 2023-06-16 21:56:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 178,072 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 14:01:46
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y, id;
    cin >> n;
    vector<tuple<int,int,int>> a(n);
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        a[i] = make_tuple(x, y, i);
    }

    sort(a.begin(), a.end());
    cout << n / 2 << '\n';
    for(int i = 0; i + 1 < n; i += 2){
        int x, y, id;
        int x2, y2, id2;
        tie(x, y, id) = a[i];
        tie(x, y, id2) = a[i + 1];
        cout << id + 1 << ' ' << id2 + 1 << '\n';
    }
}
0