結果

問題 No.1640 簡単な色塗り
ユーザー harurunharurun
提出日時 2021-06-12 17:55:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 86,180 KB
実行使用メモリ 44,236 KB
最終ジャッジ日時 2023-09-12 01:26:01
合計ジャッジ時間 57,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
27,772 KB
testcase_01 AC 2 ms
8,752 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1,857 ms
14,248 KB
testcase_05 AC 1,786 ms
13,432 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 280 ms
4,576 KB
testcase_31 AC 1,816 ms
14,628 KB
testcase_32 AC 1,547 ms
12,880 KB
testcase_33 AC 1,060 ms
9,320 KB
testcase_34 AC 1,330 ms
12,980 KB
testcase_35 AC 1,072 ms
8,716 KB
testcase_36 AC 267 ms
4,672 KB
testcase_37 AC 370 ms
5,532 KB
testcase_38 AC 1,601 ms
13,020 KB
testcase_39 AC 691 ms
7,744 KB
testcase_40 AC 740 ms
8,912 KB
testcase_41 AC 1,382 ms
12,600 KB
testcase_42 AC 829 ms
8,040 KB
testcase_43 AC 833 ms
8,820 KB
testcase_44 AC 840 ms
8,000 KB
testcase_45 AC 624 ms
7,512 KB
testcase_46 AC 307 ms
5,504 KB
testcase_47 AC 192 ms
4,552 KB
testcase_48 AC 1,671 ms
14,160 KB
testcase_49 AC 87 ms
4,376 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 WA -
testcase_53 WA -
07_evil_01.txt TLE -
07_evil_02.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long
#define Pll pair<ll,ll>

ostream& operator<<(ostream& os,const vector<pair<ll,pair<ll,ll>>>& a){
  for(pair<ll,pair<ll,ll>> i:a){
    os<<i.first<<" "<<i.second.first<<" "<<i.second.second<<"\n";
  }
  return os;
}

ostream& operator<<(ostream& os,const vector<ll>& a){
  for(ll i:a){
    os<<i<<"\n";
  }
  return os;
}

int main(){
  ll N,a,b;
  cin>>N;
  vector<ll>A(N),B(N),d(N),ans(N),check(N);
  vector<pair<ll,pair<ll,ll>>>tmp;
  for(int i=0;i<N;i++){
    cin>>a>>b;
    A.at(i)=a;
    B.at(i)=b;
    d.at(a-1)++;
    d.at(b-1)++;
  }
  for(ll i=0;i<N;i++){
    tmp.push_back({d.at(A.at(i)-1),{i,A.at(i)}});
    tmp.push_back({d.at(B.at(i)-1),{i,B.at(i)}});
  }
  sort(tmp.begin(),tmp.end());
  cerr<<tmp;
  Pll u;
  for(int i=0;i<2*N;i++){
    u=tmp.at(i).second;
    if(ans.at(u.first)==0 && check.at(u.second-1)==0){
      ans.at(u.first)=u.second;
      check.at(u.second-1)=1;
    }
  }
  cerr<<ans;
  for(int i=0;i<N;i++){
    if(ans.at(i)==0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  for(ll i:ans){
    printf("%lld\n",i);
  }
  return 0;
}
0