結果

問題 No.2353 Guardian Dogs in Spring
ユーザー HIcoderHIcoder
提出日時 2023-07-06 19:30:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,899 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 124,192 KB
実行使用メモリ 4,916 KB
最終ジャッジ日時 2023-09-27 20:24:17
合計ジャッジ時間 8,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 15 ms
4,916 KB
testcase_07 AC 16 ms
4,748 KB
testcase_08 AC 15 ms
4,756 KB
testcase_09 WA -
testcase_10 AC 14 ms
4,424 KB
testcase_11 AC 17 ms
4,784 KB
testcase_12 AC 17 ms
4,784 KB
testcase_13 AC 14 ms
4,420 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 6 ms
4,380 KB
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);

int main(){
    int N;
    cin>>N;
    

    map<int,vector<int>> mp;

    map<P,int> dogid;

    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        mp[x].push_back(y);
        dogid[make_pair(x,y)]=i;

    }
    for(auto &[x,vec]:mp){
        sort(vec.begin(),vec.end());
    }

    vector<pair<int,int>> ans;

    int k=0;

    int offset=0;
    
    pair<int,int> empty=make_pair(-1,-1);
    pair<int,int> last=empty;
    
    /*   
    int empty=-1;
    int last=empty;
    */
    
    for(auto& [x,vec]:mp){

     
        if(offset>0){
            ans.emplace_back(dogid[last],dogid[make_pair(x,vec.back())]);
            vec.pop_back();
            offset=0;
            last=empty;
        }
        
        int k=0;
        if(k+1<vec.size()){
        for(k=0;k<vec.size();k+=2){
            ans.emplace_back(dogid[make_pair(x,vec[k])],dogid[make_pair(x,vec[k+1])]);
        }
        }

        if(k!=vec.size()){
            last=make_pair(x,vec.back());
            offset=1;
        }


        /*
        if(c%2==0){
            k+=c/2;
            if(offset>0){
                ans.emplace_back(dogid[last],dogid[make_pair(x,vec.back())]);
            }
            offset=0;

            for(int k=0;k<vec.size();k+=2){
                ans.emplace_back(dogid[make_pair(x,vec[k])],dogid[make_pair(x,vec[k+1])]);
            }


        }else{
            offset=1;//つぎに繰り越し

            k+=(c-1)/2;


        }
        */
    }

    cout<<ans.size()<<endl;
    for(auto [z,w]:ans){
        cout<<z+1<<' '<<w+1<<endl;
    }
}
0